Forums / Cotonti / Support / How to show all categories and its sub categories in the list?

Macik
#39224 2014-02-27 11:50

Here it is:

function catlist($tpl = 'catlist', $items = 0, $order = '', $cat = '', $sub = true)
{

	// Specific cat
	$cats = cot_structure_children('page', $cat, (bool)$sub,false);
	$t = new XTemplate(cot_tplfile($tpl, 'plug'));

	$totalitems = sizeof($cats);
	if (!$order) shuffle($cats);
	if ($items) {
		$cats = array_slice($cats,0,$items);
	}
	foreach ($cats as $idx => $cat_name) {
		$t->assign('CAT',$structure['page'][$cat_name]);
		$t->assign('cat_name',$cat_name);
		$t->parse('MAIN.CAT_ROW');
	}

$t->parse();
return $t->text();
}

I use this function for my own. It similar to pagelist but more simplier. You can add it to `global` hook  — for example simply add it to `pagelist.global.php` file.

 

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F