Callouts by Category

4 Kommentare

  • Jim Davenport

    Hi Kate M

    The challenge here is that the Article page doesn't have a direct reference to the parent category.

    Although there are a few approaches, some more elegant than others, a simple one would be to wrap your callout in the following code on the Article page:

    {{#each article.path_steps}}
    {{#if @first}}
    {{#isnt name 'COVID-19 FAQ and Resources'}}
    Your callout
    {{/isnt}}
    {{/if}}
    {{/each}}

    Assuming 'COVID-19 FAQ and Resources' is the name of the category that you want to exclude.

    Alternatively, you could use a reference to the category ID in the isn't statement:

    {{#isnt id '123456'}}
    Your callout
    {{/isnt}}

    Where 123455 is your actual category ID.

    That should allow you to show the callout only on articles that do not sit in the COVID category.  No need to mess around with article content :D

    Hope that helps!

    Jim 

    Zenplates - Custom themes and plugins for Zendesk

    1
  • Kate M

    Hello Jim,

    Thank you so much! That worked perfectly! :)

    If we wanted to exclude an additional category, would that be possible? 

    Like...

     {{#isnt name 'COVID-19 FAQ and Resources' OR 'Category XYZ'}}

    Thank you!

    Kate

    0
  • Jim Davenport

    Hi Kate, 

    The {{isnt}} helper only allows for a comparison between two values, in this case the category name and a string ("COVID-19 FAQ and Resources").  It's a bit clunky, but you could nest isnt conditions:

    {{#isnt name 'Category 1'}}
    {{#isnt name 'Category 2'}}
    ...
    {{/isnt}}
    {{/isnt}}

    Or you could use the {{is}} helper to identity specifically which categories you'd like to show the content for:

    {{#is name 'Category 1'}}
    ...
    {{/is}}

    It's also possible to print the category ID or name to the page and then have some custom JavaScript take care of the conditional showing/hiding of content.  That might be overkill though ;)

    1
  • Kate M

    Thank you, Jim! This has been so helpful.

    Kate

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk