• 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  [ 1 post ] 
Author Message
 Post subject: Display Category name from CompanyDirectory in Summary view
PostPosted: Tue Jun 10, 2014 2:48 pm 
I needed to create a filter-by-category functionality in a website's company directory/google maps page.
See here: http://www.sundborn.com/foretag

The problem was to get and display the Category name of the chosen categoy (and format the buttons accodingly). Unfortunately the category name is not passed in the smarty-variables (as far as I understand, I might have missed something here.)

The solution was to get the category-id and look-up the category name in the database with the help of some smarty and a simple UDT:

In the tempate I used this smarty:
{assign var=catId value="/"|explode:$smarty.get.page}

to get the catId.

I can then use this simple UDT to get the category name:
global $gCms;
$db = $gCms->GetDb();

$cat_id = $params['catid'];

$data = mysql_query("SELECT * FROM  cms_module_compdir_categories")
 or die(mysql_error());

while($info = mysql_fetch_array( $data ))
    if($info['id'] ==  $cat_id)
         $cat_name = $info['long_name'];


The UDT is called by:
{getcategory catid=$catId.2}

A rather rough solution, admittedly. But it got the job done ;)

Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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:  
Hosting Nation - Managed CMSMS Hosting