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
CGCalendar: Passing event field name into a GBC
-
cpansewicz
- Forum Members

- Posts: 142
- Joined: Fri Jun 17, 2011 12:22 am
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: CGCalendar: Passing event field name into a GBC
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}
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.
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

- Posts: 142
- Joined: Fri Jun 17, 2011 12:22 am
Re: CGCalendar: Passing event field name into a GBC
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.
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

- Posts: 142
- Joined: Fri Jun 17, 2011 12:22 am
Re: CGCalendar: Passing event field name into a GBC
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?
{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

- Posts: 142
- Joined: Fri Jun 17, 2011 12:22 am
SOLVED: CGCalendar: Passing event field name into a GBC
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.
{if strpos($event.category_names, 'General') == true}
Content here
{/if}
Thanks again for this forum.
- PinkElephant
- Forum Members

- Posts: 173
- Joined: Fri Feb 06, 2009 2:08 pm
Re: SOLVED: CGCalendar: Passing event field name into a GBC
Hi,
Thanks for posting the solution. I'm not familiar with the module but a quick note on the function...
(Untested in smarty context but it seems to be the way).
Thanks for posting the solution. I'm not familiar with the module but a quick note on the function...
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:cpansewicz wrote:{if strpos($event.category_names, 'General') == true}
Code: Select all
{if strpos($event.category_names, 'General') !== false}
-
cpansewicz
- Forum Members

- Posts: 142
- Joined: Fri Jun 17, 2011 12:22 am
Re: CGCalendar: Passing event field name into a GBC
Ok. Thanks for that clarification on that code. I appreciate it!
