Sign in
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Mercury theme filter help

  • This topic has 7 replies, 3 voices, and was last updated 2 years, 11 months ago by .
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #5341
    Avatar photoYaroslav

    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
    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.


    Avatar photoYaroslav

    here is a screenshot of page

    Avatar photoshaun2k

    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.



    Avatar photoYaroslav

    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))

    Avatar photoBob

    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"}}


    {{#is "index,tag,tags,author,post"}}

    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    Avatar photoshaun2k

    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}}?




    Avatar photoshaun2k

    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}}


    {{#each @website.contentStructure.posts}}
        {{#unless isHidden}}
            {{#if mainTag}} <!-- mainTag will be empty if the post has no tags -->

    Thanks to @Bob and @Yaroslav!

    Avatar photoYaroslav

    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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.