Hello everyone.
I have three modules News, CGBlog, and CGCalendar that my client users to post News, Events and Blog items.
The client does not want the side bar titles News, Blog, or Events to appear if there are none.
The below link explains how to user a User Defined Tag for News, but $itemcount seems to be used for multiple mods, so I am not sure how to get it.
Is there not a way i can access the object of a module directly and the array?
http://wiki.cmsmadesimple.org/index.php ... fined_Tags
Accessing variables from within modules
-
- New Member
- Posts: 4
- Joined: Mon Feb 22, 2010 11:08 pm
Re: Accessing variables from within modules
Yes, you don't need a UDT for this.
You can change the moduletemplate for each module a bit by adding some smarty code.
Most modules have a variable like $itemcount, but they don't need to, or the name may vary slighly. This is how you caan do it for all cmsms modules:
You have to determine which moduletemplates you use. For News I guess you can find it in the tab "Summary Templates". The templates there use something like this:
So the variable $items is the array with all the newsitems here.
On the fisrt row of that moduletemplate you put:
and on the last row:
In CGBlog there is also the variable $items.
CGCalendar uses $events as array variable in the "Upcoming Templates".
You can change the moduletemplate for each module a bit by adding some smarty code.
Most modules have a variable like $itemcount, but they don't need to, or the name may vary slighly. This is how you caan do it for all cmsms modules:
You have to determine which moduletemplates you use. For News I guess you can find it in the tab "Summary Templates". The templates there use something like this:
Code: Select all
{foreach from=$items item=entry}
On the fisrt row of that moduletemplate you put:
Code: Select all
{if $items|@count > 0}
Code: Select all
{/if}
CGCalendar uses $events as array variable in the "Upcoming Templates".
-
- New Member
- Posts: 4
- Joined: Mon Feb 22, 2010 11:08 pm
Re: Accessing variables from within modules
Thanks for your reply.
I am able to do those from within the summary template however, the issue is I have a side bar with 3 categories (News, Events, Calendar). My client does not even want the categories to appear if there are no News, Events, or Blog entries.
So I need a way to access to basically have something like {if news itemcount != 0} but fromwithin a global content block
I am able to do those from within the summary template however, the issue is I have a side bar with 3 categories (News, Events, Calendar). My client does not even want the categories to appear if there are no News, Events, or Blog entries.
So I need a way to access to basically have something like {if news itemcount != 0} but fromwithin a global content block
Re: Accessing variables from within modules
Why don't you put the in the moduletemplate also? 

-
- New Member
- Posts: 4
- Joined: Mon Feb 22, 2010 11:08 pm
Re: Accessing variables from within modules
Haha your a genius 
