Sign in

Conditional helper: check if the custom post template is used

  • This topic has 3 replies, 2 voices, and was last updated 7 months, 2 weeks ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9855
    Avatar photoNicolas

    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 photoNicolas

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

     

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

    #9861
    Avatar photoNicolas

    Thanks Bob, it works fine

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