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

Conditional helper: check if the custom post template is used

  • #9855
    Avatar photo[anonymous]

    Hello,

    I would like to use a different stylesheet file depending on the post template used.

    https://zupimages.net/up/23/16/pu78.png

    "postTemplates": {
            "landing": "Landing page",
            "product": "Product page"
        },

    With conditional helper how to check if the post template “landing” is used?

    {{#if postTemplates}}
       <link rel="stylesheet" href="{{css "landing.css" }}">
    {{else}}
       <link rel="stylesheet" href="{{css "style.css" }}">
    {{/if}}

    Thanks

    #9856
    Avatar photo[anonymous]

    #9858
    Avatar photoBob

    Try this way:

    {{#is "post" }}
       {{#checkIf post.template '==' "landing"}}
          <link rel="stylesheet" href="{{css "landing.css" }}">
       {{else}}
          <link rel="stylesheet" href="{{css "style.css" }}">
       {{/checkIf}}
    {{/is}}
    #9861
    Avatar photo[anonymous]

    Thanks Bob, it works fine