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: How to Call Category ID number/Name without Link  (Read 3842 times)

0 Members and 1 Guest are viewing this topic.

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
How to Call Category ID number/Name without Link
« on: May 20, 2011, 02:12:22 pm »

My Gallery

I have figured out how to get the category icons without having to upload them in the gallery itself.  Here is the code, I altered my theme's theme.php file

Code: [Select]
/******************************************************************************
** Section <<<theme_display_cat_list>>> - START
******************************************************************************/
function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)
{
    global $template_cat_list, $lang_cat_list;
    if (count($cat_data) > 0) {
        starttable('100%');
        $template = template_extract_block($template_cat_list, 'header');
        $params = array(
                '{CATEGORY}' => $lang_cat_list['category'],
                '{ALBUMS}' => $lang_cat_list['albums'],
                '{PICTURES}' => $lang_cat_list['pictures'],
        );
        echo template_eval($template, $params);
    }

    $template_noalb = template_extract_block($template_cat_list, 'catrow_noalb');
    $template = template_extract_block($template_cat_list, 'catrow');
    foreach($cat_data as $category) {
        if (!isset($category['cat_icon'])) { $category['cat_icon'] = '<img src="http://www.mysite.net/cpg/images/categories/catid_(Add either the category number or name here.jpg" title="" alt="" width="80px" height="80px" border="0" hspace="0" vspace="0" />'; }
        if (!isset($category['cat_thumb'])) { $category['cat_thumb'] = ''; }
        if (count($category) == 3) {
            $params = array(
                    '{CAT_ICON}' => $category['cat_icon'],
                    '{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                    '{CAT_DESC}' => $category[1],
            );
            echo template_eval($template_noalb, $params);
        } elseif (isset($category['cat_albums']) && ($category['cat_albums'] != '')) {
            $params = array(
                    '{CAT_ICON}' => $category['cat_icon'],
                    '{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                    '{CAT_DESC}' => $category[1],
                    '{CAT_ALBUMS}' => $category['cat_albums'],
                    '{ALB_COUNT}' => cpg_float2decimal($category[2]),
                    '{PIC_COUNT}' => cpg_float2decimal($category[3]),
            );
            echo template_eval($template, $params);
        } else {
            $params = array(
                    '{CAT_ICON}' => $category['cat_icon'],
                    '{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                    '{CAT_DESC}' => $category[1],
                    '{CAT_ALBUMS}' => '',
                    '{ALB_COUNT}' => cpg_float2decimal($category[2]),
                    '{PIC_COUNT}' => cpg_float2decimal($category[3]),
            );
            echo template_eval($template, $params);
        }
    }

    if ($statistics && count($cat_data) > 0) {
        $template = template_extract_block($template_cat_list, 'footer');
        $params = array('{STATISTICS}' => $statistics);
        echo template_eval($template, $params);
    }


    if (count($cat_data) > 0)
          endtable();
        echo template_extract_block($template_cat_list, 'spacer');
}

here is the template layout

Code: [Select]
/******************************************************************************
** Section <<<$template_cat_list>>> - START
******************************************************************************/
// HTML template for the category list
$template_cat_list = <<<EOT
<!-- BEGIN header -->
        <tr>
                <td class="tableh1" width="80%" align="left">{CATEGORY}</td>
                <td class="tableh1" width="10%" align="center">{ALBUMS}</td>
                <td class="tableh1" width="10%" align="center">{PICTURES}</td>
        </tr>
<!-- END header -->
<!-- BEGIN catrow_noalb -->
        <tr>
                <td class="catrow_noalb" colspan="3"><table border="0"><tr><td align="left">{CAT_ICON}</td><td align="left"><span class="catlink">{CAT_TITLE}</span>{CAT_DESC}</td></tr></table></td>
        </tr>
<!-- END catrow_noalb -->
<!-- BEGIN catrow -->
        <tr>
                <td class="catrow" align="left"><table border="0"><tr><td>{CAT_ICON}</td><td><span class="catlink">{CAT_TITLE}</span>{CAT_DESC}</td></tr></table></td>
                <td class="catrow" align="center">{ALB_COUNT}</td>
                <td class="catrow" align="center">{PIC_COUNT}</td>
        </tr>
        <tr>
            <td class="tableb tableb_alternate" colspan="3">{CAT_ALBUMS}</td>
        </tr>
<!-- END catrow -->
<!-- BEGIN footer -->
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS}</span></td>
        </tr>
<!-- END footer -->
<!-- BEGIN spacer -->
        <img src="images/spacer.gif" width="1" height="7" border="" alt="" /><br />
<!-- END spacer -->

EOT;
/******************************************************************************
** Section <<<$template_cat_list>>> - END

Is there a way that I can call the category's id number, or the name without it including the link?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How to Call Category ID number/Name without Link
« Reply #1 on: May 20, 2011, 03:32:23 pm »

I guess you're talking about that line
Code: [Select]
        if (!isset($category['cat_icon'])) { $category['cat_icon'] = '<img src="http://www.mysite.net/cpg/images/categories/catid_(Add either the category number or name here.jpg" title="" alt="" width="80px" height="80px" border="0" hspace="0" vspace="0" />'; }?

I'm not sure what you mean with
Is there a way that I can call the category's id number, or the name without it including the link?

Are you looking for a way to modify that line so it always adds the current category ID? E.g.
?
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: How to Call Category ID number/Name without Link
« Reply #2 on: May 20, 2011, 03:40:36 pm »

yes that is exactly what I would like :D

is it possible?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How to Call Category ID number/Name without Link
« Reply #3 on: May 20, 2011, 04:05:13 pm »

According to your above code, find
Code: [Select]
        if (!isset($category['cat_icon'])) { $category['cat_icon'] = '<img src="http://www.mysite.net/cpg/images/categories/catid_(Add either the category number or name here.jpg" title="" alt="" width="80px" height="80px" border="0" hspace="0" vspace="0" />'; }and replace with
Code: [Select]
        preg_match('/<a href="index\.php\?cat=([0-9]+)">/', $category[0], $matches);
        if (!isset($category['cat_icon'])) { $category['cat_icon'] = '<img src="http://www.mysite.net/cpg/images/categories/catid_'.$matches[1].'.jpg" title="" alt="" width="80px" height="80px" border="0" hspace="0" vspace="0" />'; }
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: How to Call Category ID number/Name without Link
« Reply #4 on: May 20, 2011, 05:34:50 pm »

Thanks, it works perfectly :D
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.