Advanced search  

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

Pages: [1]   Go Down

Author Topic: [Solved]: Category Name (Title) in Theme.php  (Read 7448 times)

0 Members and 1 Guest are viewing this topic.

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
[Solved]: Category Name (Title) in Theme.php
« on: July 12, 2009, 12:55:03 am »

hi there...I have said it before, and will say it again...I think coppermine is AWESOME!!! so thanks for all your hard work on making it so...    :o

now onto my question...

I am trying to figure out how to access the category name of a current image being displayed...I am not a php pro, I would consider myself somewhat better than a novice...I searched and searched, but can't find how you guys pull the category title out...

I am hoping to be able to define it as a variable on theme.php as such:

Code: [Select]
$categoryTitle = $CURRENT_CATEGORY_DATA['title'];
I know that it doesn't exist, but what can I use to get that result?


thank you mucho!!   ;D ;D
« Last Edit: July 13, 2009, 11:11:51 am by Joachim Müller »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Logged

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
Re: Category Name (Title) in Theme.php
« Reply #2 on: July 12, 2009, 08:56:12 pm »

http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616

okay...sorry about that...  ;)


http://www.picsandass.com/pics/displayimage.php?pos=-9040  - and there is some adult content in the gallery, not this image but in the gallery...

I want to add the category name in the left corner of my filmstrip...where I have added 'Related Photos:'


 8)

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Category Name (Title) in Theme.php
« Reply #3 on: July 12, 2009, 10:36:31 pm »

Upgrade! Running cpg1.4.10 is not an option, with the most recent stable release currently being cpg1.4.25
Logged

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
Re: Category Name (Title) in Theme.php
« Reply #4 on: July 13, 2009, 04:16:15 am »

yeah I guess it has been a while since I have upgraded it...but I didn't realize its been that long...

let me get on that...  :P

in the meantime, can you explain how to extract the category title/name...I know $cat gets the category number...do I use $cat_data?

thanks!

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Category Name (Title) in Theme.php
« Reply #5 on: July 13, 2009, 07:30:25 am »

yeah I guess it has been a while since I have upgraded it...but I didn't realize its been that long...
cpg1.4.10 has been released on 2006-10-29...

in the meantime, can you explain how to extract the category title/name...I know $cat gets the category number...do I use $cat_data?
I don't remember out of the back of my head, but I'm pretty sure that the category name doesn't get populated globally in theme.php. It get's populated if needed, i.e. on index pages. It doesn't get populated on displayimage pages. Your best bet is the breadcrumb. Alternatively, run the additional queries (as categories can be nested indefinitely at least in theory, the loop will need to be recursive) in a custom function. To get an idea how to accomplish this code-wise, take a look at the code in catmgr.php - find function get_subcat_data($parent, $ident = '') and simplify as you see fit.
Logged

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
Re: Category Name (Title) in Theme.php
« Reply #6 on: July 13, 2009, 10:29:21 am »



cpg1.4.10 has been released on 2006-10-29...

man...what a long strange trip its been...  8)


I don't remember out of the back of my head, but I'm pretty sure that the category name doesn't get populated globally in theme.php. It get's populated if needed, i.e. on index pages. It doesn't get populated on displayimage pages. Your best bet is the breadcrumb. Alternatively, run the additional queries (as categories can be nested indefinitely at least in theory, the loop will need to be recursive) in a custom function. To get an idea how to accomplish this code-wise, take a look at the code in catmgr.php - find function get_subcat_data($parent, $ident = '') and simplify as you see fit.

after trying to get this figured out (the best I could do was get the last category created or the last category alphabetically to be called)...frustrated, but not defeated, I remembered that you noted that it gets populated on the index pages...which led me to search for where it gets populated...which led me to search for the term "CURRENT"...and lo-and-behold, there is actually a "$CURRENT_CAT_NAME" which does exactly what I am looking to do...heheheheheeee....  :o


thanks for the help...it is much appreciated...and thanks for the long past due update reminder...



for those of you looking at this post for the answer...what I did was add "$CURRENT_CAT_NAME" to the global definitions of the function:

Code: [Select]
function theme_display_image($nav_menu, $picture, $votes, $pic_info, $comments, $film_strip)
{
    global $CONFIG,$CURRENT_ALBUM_DATA,$CURRENT_PIC_DATA,$CURRENT_CAT_NAME;

and then I was able to use where I saw fit:


Code: [Select]

print "Related Photos:<br><span class=\"alblink\"><a href=\"thumbnails.php?album=search&amp;search=$CURRENT_CAT_NAME\">$CURRENT_CAT_NAME</a></span><br><br>";


enjoy life!!!

peace

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Category Name (Title) in Theme.php
« Reply #7 on: July 13, 2009, 11:11:37 am »

Thanks for resolving your thread. Actually, $CURRENT_CAT_NAME gets populated within the breadcrumb function definition in include/functions.inc.php - the corresponding code snippet is
Code: [Select]
        $category_array = array();

        // first we build the category path: names and id
        if ($cat != 0)
        { //Categories other than 0 need to be selected
                if ($cat >= FIRST_USER_CAT)
                {
                    $user_name = get_username($cat - FIRST_USER_CAT);
                    if (!$user_name) $user_name = 'Mr. X';

                    $category_array[] = array($cat, $user_name);
                    $CURRENT_CAT_NAME = sprintf($lang_list_categories['xx_s_gallery'], $user_name);
                    $row['parent'] = 1;
                }
                else
                {
                    $result = cpg_db_query("SELECT name, parent FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
                    if (mysql_num_rows($result) == 0)
                        cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
                    $row = mysql_fetch_array($result);

                    $category_array[] = array($cat, $row['name']);
                    $CURRENT_CAT_NAME = $row['name'];
                    mysql_free_result($result);
                }

                while($row['parent'] != 0)
                {
                    $result = cpg_db_query("SELECT cid, name, parent FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
                    if (mysql_num_rows($result) == 0)
                        cpg_die(CRITICAL_ERROR, $lang_errors['orphan_cat'], __FILE__, __LINE__);
                    $row = mysql_fetch_array($result);

                    $category_array[] = array($row['cid'], $row['name']);
                    mysql_free_result($result);
                } // while

                $category_array = array_reverse($category_array);
        }
Logged

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
Re: [Solved]: Category Name (Title) in Theme.php
« Reply #8 on: July 13, 2009, 11:26:52 am »

 ;)

thanks...

now I know where it gets populated...but I certainly have a long way to go before I will fully understand how it gets populated....I couldn't seem to isolate it in function get_subcat_data...

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Solved]: Category Name (Title) in Theme.php
« Reply #9 on: July 13, 2009, 11:28:32 am »

Does that matter? To use it within your custom function, just make it global and you're fine.
Logged

freesouljah

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 116
  • Can you feel the Love?
    • freesouljah.com
Re: [Solved]: Category Name (Title) in Theme.php
« Reply #10 on: July 13, 2009, 11:38:03 am »

Does that matter?

hehe....not really...but it would be nice...I would like to understand cpg and php more...but there will be more problems that arise which will require digging and investigating, and maybe it will click in my mind at that point...


until that day...thank you kindly for your insight and patience...


peace
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 20 queries.