How to Call Category ID number/Name without Link How to Call Category ID number/Name without Link
 

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]

Main Menu

How to Call Category ID number/Name without Link

Started by SolidSnake2003, May 20, 2011, 02:12:22 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

SolidSnake2003

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

/******************************************************************************
** 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

/******************************************************************************
** 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?

Αndré

I guess you're talking about that line
        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
Quote from: SolidSnake2003 on May 20, 2011, 02:12:22 PM
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.
?

SolidSnake2003

yes that is exactly what I would like :D

is it possible?

Αndré

According to your above code, find
        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
        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" />'; }

SolidSnake2003