Code: Select all
<?php
/* @var $cms Shop */
$cms = $this;
$templateName = !empty($params['template']) ? $params['template'] : null;
$categories = $cms->getCategories();
foreach ($categories as &$category) {
$category['link'] = $cms->_createFront('category_details', $id, $returnid, array('category_id' => $category['id']), false, $cms->_url_prefix . $category['slug']);
}
$this->smarty->assign('categories', $categories);
$template = $cms->getTemplateByTitle($templateName, 'categories_templates_tab');
if (!$template) {
$template = $cms->getDefaultTemplateForType('categories_templates_tab');
}
echo $cms->ProcessTemplateFromData($template['template']);
Code: Select all
<section>
<a href="http://www.faab.local.pl/shop/bart-czyz/" title="Bart Czyz">Bart Czyz</a>
<a href="http://www.faab.local.pl/shop/jan-kowalski-local/" title="Jan Kowalski local">Jan Kowalski local</a>
</section>
The next step is makes routes for this categories, so just like in News.module.php i wrote that code in InitializeFrontend of my module
Code: Select all
$categoriesSlugs = $this->getCategoriesSlugs();
$productsSlugs = $this->getProductsSlugs();
$gCms = cmsms();
$contentops = $gCms->GetContentOperations();
$category_page = $contentops->GetDefaultContent();
if (!empty($categoriesSlugs)) {
foreach ($categoriesSlugs as $category) {
$parms = array(
'action' => 'category_details',
'returnid' => $category_page,
'category_id' => $category['id']
);
$condition = (!empty($category['url'])) ? $category['url'] : $category['slug'];
//$this->_url_prefix contains 'shop/'
$urlString = $this->_url_prefix . $condition;
$route = new CmsRoute($urlString, $this->GetName(), $parms, TRUE);
debug_display($urlString);
cms_route_manager::register($route);
}
}
Code: Select all
Debug: (0.163034) - (usage: 5178944) - (peak: 5219504)
CmsRoute Object
(
[_dest:CmsRoute:private] => Shop
[_content_id:CmsRoute:private] =>
[_term:CmsRoute:private] => shop/bart-czyz
[_defaults:CmsRoute:private] => Array
(
[action] => category_details
[returnid] =>
[category_id] => 4
)
[_absolute:CmsRoute:private] => 1
[_results:CmsRoute:private] =>
)
Debug: (0.16325) - (usage: 5180260) - (peak: 5236284)
CmsRoute Object
(
[_dest:CmsRoute:private] => Shop
[_content_id:CmsRoute:private] =>
[_term:CmsRoute:private] => shop/jan-kowalski-local
[_defaults:CmsRoute:private] => Array
(
[action] => category_details
[returnid] =>
[category_id] => 5
)
[_absolute:CmsRoute:private] => 1
[_results:CmsRoute:private] =>
)