• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Accessing variables from within modules
PostPosted: Fri Mar 12, 2010 11:42 pm 
Offline
New Member

Joined: Mon Feb 22, 2010 11:08 pm
Posts: 4
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


Top
 Profile  
 
 Post subject: Re: Accessing variables from within modules
PostPosted: Sat Mar 13, 2010 9:03 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 2820
Location: The Netherlands
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:
Code:
{foreach from=$items item=entry}


So the variable $items is the array with all the newsitems here.

On the fisrt row of that moduletemplate you put:
Code:
{if $items|@count > 0}


and on the last row:
Code:
{/if}


In CGBlog there is also the variable $items.
CGCalendar uses $events as array variable in the "Upcoming Templates".

_________________
The Fourth Dutch CMS Made Simple Workshop on April 9 2011 was great fun! Read all about it here


Top
 Profile  
 
 Post subject: Re: Accessing variables from within modules
PostPosted: Sat Mar 13, 2010 4:09 pm 
Offline
New Member

Joined: Mon Feb 22, 2010 11:08 pm
Posts: 4
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



Top
 Profile  
 
 Post subject: Re: Accessing variables from within modules
PostPosted: Sat Mar 13, 2010 4:39 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 2820
Location: The Netherlands
Why don't you put the

in the moduletemplate also?  ;)


_________________
The Fourth Dutch CMS Made Simple Workshop on April 9 2011 was great fun! Read all about it here


Top
 Profile  
 
 Post subject: Re: Accessing variables from within modules
PostPosted: Sat Mar 13, 2010 5:43 pm 
Offline
New Member

Joined: Mon Feb 22, 2010 11:08 pm
Posts: 4
Haha your a genius :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner