[SOLVED] CGCalendar - Browse by Category

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
richardjkeys
Forum Members
Forum Members
Posts: 15
Joined: Mon Sep 27, 2010 12:14 pm

[SOLVED] CGCalendar - Browse by Category

Post by richardjkeys »

Hi,

I'm using the CGCalendar module on my events section.

I'd like to create a dynamic category list (to use as sub nav) which filters the events; much like the Browse by Category option does in the news module.

Has anyone devised a simple solution for this?

If not, could anyone point me in the right direction to 'copy' the functionality of this from the news module into the CGCalendar module? I'm new to CMSMS plugins, but my PHP isn't too bad - I think this might be a useful solution for others too.

Any help is greatly appreciated.

Regards,

Rich
Last edited by richardjkeys on Wed Oct 06, 2010 7:31 am, edited 1 time in total.
Peciura

Re: CGCalendar - Browse by Category

Post by Peciura »

Categories are saved on table `cms_module_cgcalendar_categories`.
Create list of categories,
add links with extra url parameter (e.g. "cgc_cat") to the same page where is CGCalendar tag

Code: Select all

cms_module module='CGCalendar' category=$smarty.get.cgc_cat}
It will display events of category stored in url, or all events if no category (url param) is set.
richardjkeys
Forum Members
Forum Members
Posts: 15
Joined: Mon Sep 27, 2010 12:14 pm

Re: CGCalendar - Browse by Category

Post by richardjkeys »

Hi,

Thanks for the advice.

Could you point me in the right direction for creating this list? As I said, I'm new to CMSMS plugins & modules -  am I right in thinking I could create a tag for this event 'sub-navigation'?

Rich
Peciura

Re: CGCalendar - Browse by Category

Post by Peciura »

a. Create UDT 'get_cgcalendar_categories'

Code: Select all

/**
* Get list of CGCalendar categories and assign to Smarty variable.
*
* @params	string	$params['assign']	Mandatory. Name of variable to assign result
*/

$assign = trim($params['assign']);

if (!empty($assign)){
	
	$gCms = cmsms(); // global $gCms;
	$db = $gCms->GetDB(); // cms_utils :: get_db();
	$smarty = $gCms->GetSmarty(); // cms_utils :: get_smarty();
	$dbresult = FALSE;

	$query = 'SELECT * FROM `'.cms_db_prefix().'module_cgcalendar_categories` ORDER BY `category_order`, `category_name`, `category_id`';
	
	$dbresult = $db->GetArray($query);
	if(!empty($dbresult)){
		$smarty->assign($assign, $dbresult);
	}
}
b. Create list of links to calendar page for each category. For pretty url use '?' instead of '&'
{get_cgcalendar_categories assign='cgc_cats'}
{if !empty($cgc_cats)}

{foreach from=$cgc_cats item='cgc_cat'}
{cms_selflink page=$page_alias urlparam="&cgc_cat=`$cgc_cat.category_name`" title="`$cgc_cat.category_name`" text="`$cgc_cat.category_name`"}
{/foreach}

{/if}
c. And finally, add tag you already know on calendar page.

Code: Select all

{cms_module module='CGCalendar' category=$smarty.get.cgc_cat}
richardjkeys
Forum Members
Forum Members
Posts: 15
Joined: Mon Sep 27, 2010 12:14 pm

Re: CGCalendar - Browse by Category

Post by richardjkeys »

Excellent!

That works a treat, thank you Peciura  :D
Post Reply

Return to “Modules/Add-Ons”