CGCalendar: Passing event field name into a GBC

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

CGCalendar: Passing event field name into a GBC

Post by cpansewicz »

Hi,

Is it possible to pass a field name into the name of a global content block in an event template? This is CGCalendar 1.16.1.

For instance,
{if $event.fields.name != ""}
{global_content name='{$event.fields.name)'}
{/if}

Thank you,
Camille
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: CGCalendar: Passing event field name into a GBC

Post by calguy1000 »

Single quotes are literals.... smarty does not expand their contents.
Smarty will attempt to expand the contents of double quotes.

But in this case, none of that matters.

{if $event.fields.name != ''}
{global_content name=$event.fields.name}
{/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Passing event field name into a GBC

Post by cpansewicz »

Thank you so much. In a similar question, is it possible to code the template so that if I choose a category to place the event in, that category name will populate the name of the GBC?

So if choose my event to be under "General", then the GBC would be {global_content name='General'}? I've tried this is different ways, and haven't been able successfully code this.
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Passing event field name into a GBC

Post by cpansewicz »

I started with:
{if $event.category_names == "General"}
{global_content name='General'}
{/if}

But that doesn't seem to work. Maybe because sometimes an event will be in several categories, so I would have to write, if the category name includes?
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

SOLVED: CGCalendar: Passing event field name into a GBC

Post by cpansewicz »

In case anybody else is looking to do something similar, if you have an event that is in several categories, but want to sync content into the template based on one of those categories, this is the code that works:

{if strpos($event.category_names, 'General') == true}
Content here
{/if}

Thanks again for this forum.
User avatar
PinkElephant
Forum Members
Forum Members
Posts: 173
Joined: Fri Feb 06, 2009 2:08 pm

Re: SOLVED: CGCalendar: Passing event field name into a GBC

Post by PinkElephant »

Hi,

Thanks for posting the solution. I'm not familiar with the module but a quick note on the function...
cpansewicz wrote:{if strpos($event.category_names, 'General') == true}
strpos() returns Boolean FALSE or the numeric position of first instance using an index starting at zero. To avoid position '0' being evaluated as false an exact test is required:

Code: Select all

{if strpos($event.category_names, 'General') !== false}
(Untested in smarty context but it seems to be the way).
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Passing event field name into a GBC

Post by cpansewicz »

Ok. Thanks for that clarification on that code. I appreciate it!
Post Reply

Return to “Modules/Add-Ons”