Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: How can I differentiate between top-level and sub categories?  (Read 1975 times)

0 Members and 1 Guest are viewing this topic.

mmseng

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
How can I differentiate between top-level and sub categories?
« on: August 12, 2010, 01:11:26 pm »

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!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15759
Re: How can I differentiate between top-level and sub categories?
« Reply #1 on: September 01, 2010, 04:39:18 pm »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.