TinyPortal
Development => Support => Topic started by: ElShotte on September 12, 2008, 02:32:34 PM
Hey guys, I am trying to write a custom action that will display all my categories, and under each category, indent and display the subs as well. I've looked into the DB, and there is no field that specifies that a category is in fact a sub, yet if you go to TinyPortal Admin > Articles > Categories it places and indents them underneath the proper categories. So my question is, how do I tell if a category is a sub?
Please read the Posting Guidelines (http://www.tinyportal.net/index.php?topic=581)
http://www.tinyportal.net/index.php?topic=19495.0
This is how I did it:
echo '
<div style="padding-left:200px; padding-right:10px;"><ul>';
foreach($context['TPortal']['categories'] as $mg){
if($mg['parent']=='' || $mg['parent']=='0'){
{
echo '
<li>' ,$mg['name'] , '';
echo '
</li>';
//Checks and displays subcategories
foreach($context['TPortal']['categories'] as $bmg){
if($bmg['parent']==$mg['id']){
echo ' <a href="' . $scripturl . '?cat=' . $bmg['id'] . '">' , $bmg['name'] , '</a><br />';
}
}
}
}
echo '
</ul></div>';
}