Page 1 of 1

CGCalendar: Add Category Logic to Event Detail Page

Posted: Thu Feb 11, 2016 5:41 pm
by cpansewicz
Hi,

I would like to add logic to my event detail page, where if an event falls in a certain category, specific content would show up. Does this code look correct to add to the Calendar detail page template?

{if $event.category_names == 'Category Name'}
<aside>
{global_content name='content' assign='content'}
{eval var=$content}
</aside>
{/if}

Thank you.

Re: CGCalendar: Add Category Logic to Event Detail Page

Posted: Fri Feb 12, 2016 1:36 am
by Jeff
Calling the global_content will render it through smarty the {eval} isn't needed.

Code: Select all

{global_content name='content'}

Re: CGCalendar: Add Category Logic to Event Detail Page

Posted: Tue Mar 22, 2016 5:20 pm
by cpansewicz
Yes. Thanks for getting back to me. Even if I eliminate the eval variable, the logic isn't calling in the global content. Is there something else I am missing?

Thanks!

Re: CGCalendar: Add Category Logic to Event Detail Page

Posted: Tue Mar 22, 2016 5:54 pm
by Jeff
What isn't working the {global_content} call? or the {if}?

Try debugging with printing

Code: Select all

<pre>{$event|print_r}</pre>

Re: CGCalendar: Add Category Logic to Event Detail Page

Posted: Tue Mar 22, 2016 6:51 pm
by cpansewicz
I was able to add this into my template and see the results. It is this part of the code that isn't working:

{if $event.category_names == 'Category Name'}

I know what the issue is, but don't know how to change the code. The issue is that the event belongs to several categories, and does not just equal one Category Name. How would I change the if statement to say that.

Thanks!

Re: CGCalendar: Add Category Logic to Event Detail Page

Posted: Tue Mar 22, 2016 11:16 pm
by paulbaker
Use something like strstr to find a string within a string? See
http://www.smarty.net/forums/viewtopic.php?p=66879