TinyPortal

Development => Support => Topic started by: ElShotte on September 12, 2008, 02:32:34 PM

Title: How does the page on TP Admin > categories work
Post 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?
Title: Re: How does the page on TP Admin > categories work
Post by: G6Cad on September 12, 2008, 02:59:44 PM
Please read the Posting Guidelines (http://www.tinyportal.net/index.php?topic=581)
Title: Re: How does the page on TP Admin > categories work
Post by: IchBin on September 12, 2008, 03:55:52 PM
http://www.tinyportal.net/index.php?topic=19495.0
Title: Re: How does the page on TP Admin > categories work
Post by: ElShotte on September 12, 2008, 07:56:52 PM
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 '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . $scripturl . '?cat=' . $bmg['id'] . '">' , $bmg['name'] , '</a><br />';
}
}
            }
}
echo '
</ul></div>';
}