News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

Number of Registered Users in Statistics Bar

Started by just_some_guy, October 17, 2007, 03:51:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

just_some_guy

Number of Registered Users in Statistics Bar
================================

CPG 1.4x

This mod will add the number of registered users to the statistics bar on the main page.
So you will end up with something like this:

"339 files in 94 albums and 10 categories with 169 comments viewed 22444 times by 1321 registered users "

This mod is very simple. Here are the instructions:

Step 1:

Its best practice to backup your files first.

Step 2:

Preparation:

Open themes/sample/theme.php

find: at line 224

<!-- BEGIN footer -->
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS}</span></td>
        </tr>
<!-- END footer -->


and paste that code into your theme.php.

find: around line 1443

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_noabl = 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_thumb'])) { $category['cat_thumb'] = ''; }
        if (count($category) == 3) {
            $params = array('{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1]
                );
            echo template_eval($template_noabl, $params);
        } elseif (isset($category['cat_albums']) && ($category['cat_albums'] != '')) {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => $category['cat_albums'],
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            echo template_eval($template, $params);
        } else {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => '',
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $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');
}


And copy that function into your theme.php

Editing - If you have the above content in your theme.php file then you will not need to copy from the sample theme.php.

This will involve editing the content you pasted from the sample theme.php.

Step 3.  Open theme.php

Find:

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


Replace with:

$result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}users");
$reg_usr = mysql_num_rows($result);



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

echo template_eval($template, $params);
    }



Step 4.

Find:

<!-- BEGIN footer -->
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS}</span></td>
        </tr>
<!-- END footer -->


Replace with:

<!-- BEGIN footer -->




       
        <tr>

                <td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS} by <strong>{REG_USR}</strong> registered users </span></td>
        </tr>


<!-- END footer -->


And there you go, finished,

just_some_guy

If a Dev Team Member would move this to the Mods Statistics section that would be great.

Thanks Frantz for the notice about the $CONFIG.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Hein Traag

Good idea and nice work. But by displaying it like this it looks like only registered users can view the pictures. So either that option has been set and normal unregistered users do not see anything or you should maybe make it like "339 files in 94 albums and 10 categories with 169 comments viewed 22444 times and we have 1321 registered users "


just_some_guy

I see what you mean Hein. If you wish to change the "by X registered users " edit as follows:

find the


<td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS} by <strong>{REG_USR}</strong> registered users </span></td>


section, and change the text around <strong>{REG_USR}</strong>

for example if you wished to have: "and we have X registered users"

use this code:


<td colspan="3" class="tableh1" align="center"><span class="statlink">{STATISTICS} and we have <strong>{REG_USR}</strong> registered users </span></td>


Thanks for the suggestion Hein.   
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

jolly

I did it, but the number of registered users is not display.
{REG_USR}  shown  nothing.
I cannot post link to my gallery ( bandwidth limit exceed) but i tried on my local copy. Does not work.

Joachim Müller

You've been told so often how support works ::). When will you start doing as suggested? For the last time: read up board rules and do exactly as suggested there. In this particular case, you should have posted a link to your gallery and a copy of your changes as attachment to your posting.

jolly

Does it matter, where this code should be past in theme.php ?
Copy here and there, but still without effect
It seemed to me that this has no significance. My theme.php is already quite heavily modified, and this may be the reason.

Anyway, below you can find attached my theme.php with code. Please, help me, and show what is wrong. My gallery is available at www.foto-wpadka.pl



Joachim Müller

1) Your gallery is outdated
2) Your gallery contains adult content. As per board rules, you should have posted a warning with the link.
3) The "Powered by Coppermine" tag has deliberately been disabled (setting the font size to zero), which is a licence breach and a sign of stupidity
4) The google analytics code has been applied improperly, which is unrelated, but silly just as well
5) Tracking your user account shows that you probably are the same person as the banned user nidhhog, so you have been under observation anyway.

I'm fed up with you. You are banned from this forum permanently. Do not dare to re-register. Restore the Coppermine credits immediately or uninstall coppermine from your website.

uag uag

-I do not offend you.
-Please, dont call me " stupid" because i am not.
-The fact, you are some kind of "guru" here, does not give you right to offend me.
-Size of font is not set to 0. Tag was moved permanently.

Joachim Müller

I told you that you're not allowed to re-register, yet you did, even using a mockery of my nickname. Don't behave like a moron again. Just go away and stay away.