How can I differentiate between top-level and sub categories? How can I differentiate between top-level and sub categories?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

How can I differentiate between top-level and sub categories?

Started by mmseng, August 12, 2010, 01:11:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mmseng

Hi, I'm working on a heavy custom modification of the prorandom theme. I've been marginally successful in changing the general layout to look more tableless (although it's mostly for show). However I'm having difficulties giving different visual styles to different levels of category.

On my main index page I am trying to have top-level categories display one way, while sub-categories and sub-sub-categories display differently. However, the way CPG is coded, there seems to be no way to determine a category's nesting-depth. Any ideas on this?

Here is the link to my work in progress: http://images.mattseng.com/?theme=procustom

You'll have to forgive the layout glitches. I haven't iron out all the bugs yet, but the general nesting layout is what I'm concerned with now. You'll notice that there are three primary categories displayed on this page (not including any actual albums). There's "Travel", "China (2010)", and "Home". "Travel" and "Home" are top-level categories, while "China (2010)" is a sub-category of the "Travel" category. However, because I cannot find a way to determine the depth of a category during run-time, the same visual style is applied to all three of these categories, making the layout confusing and inconsistent. Can anyone give me a hint as to anything I might be able to do to resolve this?

The only solution that comes to mind is that, since the categories are continually nested farther and farther to the right (from the left border) as they become deeper in the tree, I might be able to use PHP to count the number of spacers that are used. But obviously it would be much more preferable to have some way to simply pull the nesting-depth of the current category straight from the database.

Thanks for any help,
== Matt

P.S. Besides all the tables, great app by the way!

ΑndrĂ©

You could check if the parent of the category is equal to 0 (= top level) or greater than 0 (it's a sub category). If it's a sub category, you can check the parent category what its parent category is and so on.