TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,022
  • Total Topics: 21,332
  • Online today: 725
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 243
  • Total: 243

How does the page on TP Admin > categories work

Started by ElShotte, September 12, 2008, 02:32:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ElShotte

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?



ElShotte

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>';
}

This website is proudly hosted on Crocweb Cloud Website Hosting.