Display Category name from CompanyDirectory in Summary view
Posted: 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:
to get the catId.
I can then use this simple UDT to get the category name:
The UDT is called by:
A rather rough solution, admittedly. But it got the job done
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:
Code: Select all
{assign var=catId value="/"|explode:$smarty.get.page}
I can then use this simple UDT to get the category name:
Code: Select all
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'];
}
}
print_r($cat_name);
Code: Select all
{getcategory catid=$catId.2}