Loading...
 
Architecture / Installation

Architecture / Installation


If statement with category

posts: 4656 Japan

I want to have a dynamic content block displayed by tiki-show_page.tpl only for a particular Category. I tried
{if $is_categorized eq 'y' and $parentId eq '2'}{content id=1}{/if} but that doesn't work.

This will work — {if $is_categorized eq 'y'}{content id=1}{/if} — showing content on any page that is categorized. But how can I limit the display to a single particular category?

TIA.

-- Gary - zukakakina.com

posts: 3665 United States

I'll try the easy answer first.... Did you try nesting the statement:

{if ($is_categorized eq 'y') and ($parentId eq '2')}{content id=1}{/if}

Also, try putting a {$parentId} just before the if statement to display the actual value of parentId.

HTH,

-Rick

> I want to have a dynamic content block displayed by tiki-show_page.tpl only for a particular Category. I tried
> {if $is_categorized eq 'y' and $parentId eq '2'}{content id=1}{/if} but that doesn't work.
>
> This will work — {if $is_categorized eq 'y'}{content id=1}{/if} — showing content on any page that is categorized. But how can I limit the display to a single particular category?
>
> TIA.
>
> — Gary - zukakakina.com
>

posts: 4656 Japan

> I'll try the easy answer first.... Did you try nesting the statement:
>
> {if ($is_categorized eq 'y') and ($parentId eq '2')}{content id=1}{/if}

Didn't help, I'm afraid.

> Also, try putting a {$parentId} just before the if statement to display the actual value of parentId.

Nothing is displayed, so I guess something needs to be included first. Trying to get some clues from other files. Thanks for trying (more ideas welcome ;-) ).

-- Gary


posts: 4656 Japan

> I want to have a dynamic content block displayed by tiki-show_page.tpl only for a particular Category. I tried
> {if $is_categorized eq 'y' and $parentId eq '2'}{content id=1}{/if} but that doesn't work.

This is the solution provided by luciash and toggg on #tikiwiki:

Copy to clipboard
{foreach name=u key=k item=i from=$catp}{if $k eq '2'}{content id=1}{/if}{/foreach}

So if the page's category is 2, then content id=1 is displayed. I have a group of pages that I want to have some not-editable-by-nonadmins content displayed at the top, and this does the job.

Thanks again to those two for the answer.

-- Gary - zukakakina.com