Loading...
 
Features / Usability

Features / Usability


Custom HTML to display image based on Category and /tiki-print.php

posts: 72 United States

I'd like to display an image only for print view, and only for certain categories by adding some code to the Custom HTML section of Look & Feel.

I can control display per category using this:

Copy to clipboard
{if isset($objectCategoryIds) and in_array(89, $objectCategoryIds)} {literal} <img src="http://mysite/tiki-download_file.php?fileId=2"> {/literal} {/if}

And I can control display for only print view like this:

Copy to clipboard
{if $SCRIPT_NAME eq '/tiki-print.php'} <img src="http://mysite/tiki-download_file.php?fileId=2"> {/if}

How can I combine the two so that the image only displays for print view and certain category specified?


posts: 72 United States

Thanks for the reply Rick! I tried using "AND" to make a multi-contitional statement (see below), but it does not work. I don't see the image in the header.

Copy to clipboard
{if $SCRIPT_NAME eq '/tiki-print.php' AND isset($objectCategoryIds) AND in_array(123, $objectCategoryIds)} ... {/if}

If I use:
Copy to clipboard
{if isset($objectCategoryIds) AND in_array(123, $objectCategoryIds)} ... {/if}
The image will show in the header of the regular page view (/tiki-index.php?page=), but not in print view.

If I use:
Copy to clipboard
{if $SCRIPT_NAME eq '/tiki-print.php'} ... {/if}
The image will show in the print view (/tiki-index.php?page=), but for all categories.

Is it possible that the
Copy to clipboard
{if isset($objectCategoryIds) AND in_array(123, $objectCategoryIds)}
code doesn't work on the print view because it is not categorized?

I tried to test this by entering into the Custom HTML head Content: field:
Copy to clipboard
{if !empty($objectCategoryIds)} NOT categorized {else} AM categorized {/if}
What is odd is that it shows "NOT categorized" in the header of page view, and "AM categorized" on the print view. That's the oposite of what I expected to see. Now I'm really confused.


Is there any way to confirm that $objectCategoryIds is set in print view by looking at the tpl files? Which ones should I check? tiki-show_page.tpl, tiki-print.tpl? And what to look for?