Mercury theme filter help
-
March 12, 2021 at 4:25 pm #5341
[anonymous]
Good day to all and also to Bob, who is always answering to me and helping here. I need your help again.
I like the way how mercury theme filtet is working. I don’t need it on main page (in index.hbs) so I decided to transfere this functional to another page. And, as I expected, it is not working. My steps:
1. I created alternative post template post-portfolio.hbs
2. In config.json I added"postTemplates": { "portfolio": "portfolio filter" },3. Created a post, hide it, exclude it from main page and chose post template “portfolio filter”
4. In alternative post template post-portfolio.hbs I copied all from default index.hbs (where filters were).
5. I created three tags, three posts. To each post I added a tag.Now, when I am entering …/preview/portfolio.html I see that head, navbar, footer are working. Then I can see that the first part of filter is showing (where navigation is) and then I see endless loading (circle) but no posts cards next after filter navigation. In dev tools in console there is no errors or warnings.
What did I missed? Help me please.
March 12, 2021 at 4:26 pm #5342
[anonymous]
here is a screenshot of page
March 12, 2021 at 7:23 pm #5344
[anonymous]
I’m also testing out something similar.
Replacing {{#each posts}} to {{#each @website.contentStructure.posts}} in the post template would show all the cards/posts like the front page.
However, filtering did not work. I think there may be some changes needed in the javascripts but I’m not there yet.
March 13, 2021 at 8:57 am #5351
[anonymous]
I looked at filter code in script tag in footer
{{#checkIf @config.custom.frontSource '==' "default"}}next line is
{{#is "index,tag,tags,author,post-portfolio"}}so I added “post-portfolio” there and after {{else}} , but it didn’t helped.
Thanks for {{#each @website.contentStructure.posts}} – good idea on future))
March 14, 2021 at 7:27 am #5361
Bob
The post-portfolio template is an alternate post template and refers to the post context, so copying the index content to the new post template just won’t work. The @shaun2k “trick” should help here.
I don’t have much time now to check if everything works and provide you a complex solution, but from what I can see there is a wrong “is” helper argument, so maybe it will help you:
instead of:
{{#is "index,tag,tags,author,post-portfolio"}}use:
{{#is "index,tag,tags,author,post"}}March 14, 2021 at 9:33 am #5365
[anonymous]
Thanks @Bob for the suggested change to the “is” helper.
The filtering part is working but hidden posts are also shown in the listing.
How do we omit hidden posts when using {{#each @website.contentStructure.posts}} instead of {{#each posts}}?
Thanks.
March 14, 2021 at 10:16 am #5366
[anonymous]
To add to my last post, I figured out how to omit posts that are marked as “hidden” or without any tag from the post listing by replacing
{{#each posts}} <articlewith
{{#each @website.contentStructure.posts}} {{#unless isHidden}} {{#if mainTag}} <!-- mainTag will be empty if the post has no tags --> <articleThanks to @Bob and @Yaroslav!
March 15, 2021 at 9:49 am #5376
[anonymous]
This is fantastic! Everything works just like I wanted)) Once again, thank you Bob, for helping us to learn Publii. Thank you shaun2k for sharing your great ideas and experience, it helped me a lot.