1

Topic: Total number of Males and Femlas in account Cp stats

i did this myself the other day
and it works for me

so first u will have to edit these files so make sure u make a backup of them
i added my code in the files to look estethical

includes/cp/cp.stats.php
includes/languages/english/lang.cp.stats.php
includes/templates/stats.tpl


First one we edit is: cp.stats.php
search for:

// Get total members on the server

after the last "}" in that block of code add this code:

        //------------------------------------------------
    // Get members on the server females/males
    //------------------------------------------------
    
    // Males
    $result = $DB->query("SELECT count(*) as totalmembersm FROM " . DB_PREFIX . "members_data WHERE data_gender1='1'");
    $obj = $DB->fetch_object($result); 
    $total_male_users = $obj->totalmembersm ? $obj->totalmembersm : 0;    

    // Females
    $result = $DB->query("SELECT count(*) as totalmembersf FROM " . DB_PREFIX . "members_data WHERE data_gender1='2'");
    $obj = $DB->fetch_object($result); 
    $total_female_users = $obj->totalmembersf ? $obj->totalmembersf : 0;

search for:

Assign template vars

add these at the end:

$TEMPLATE->assign("total_male_users", $total_male_users);
$TEMPLATE->assign("total_female_users", $total_female_users);

save the file

Next one is: lang.cp.stats.php
open the file and add these rows before the closing of the array:

"males_females1"=>
"Total males/females",

"males_females2"=>
"Site males/females",

"total_male_users"=>
"Total male users",

"total_female_users"=>
"Total female users",

"males"=>
"Males",

"females"=>
"Females",

save the file and close it

No the stats.tpl file

Open it and search for:

<td class="gridHeader">{lang:"stats","total_server_messages"}</td>

should be the last row in that table code

add under it:

<tr>
                        <td class="gridHeader">{lang:"stats","males_females1"}</td>
                        <td class="gridHeader" style="text-align: center">{lang:"stats","males"}</td>
                        <td class="gridHeader" style="text-align: center">{lang:"stats","females"}</td>
                    </tr>
                    <tr>
                        <td class="gridLabels1">{lang:"stats","males_females2"}</td>
                        <td class="gridValue1" style="text-align: center">{total_male_users}</td>
                        <td class="gridValue1" style="text-align: center">{total_female_users}</td>
                    </tr>

save the file and close it

upload the edited files and check your admin cp -> stats
and look in the right side at the bottom of the stats right under: Total messages

Cheers

Last edited by jwysocki73 (2009-07-22 08:14:30)

2

Re: Total number of Males and Femlas in account Cp stats

Well done jwysocki73

I have two additions that will make your mod work

1- You need to assign template variables

In 'cp.stats.php' look for this line:

    //------------------------------------------------
    // Assign template vars
    //------------------------------------------------

insert:

$TEMPLATE->assign("total_male_users", $total_male_users);
$TEMPLATE->assign("total_female_users", $total_female_users);

2 - Use your own system values for total_male_users and total_female users

where '25' is your database number value  for male

"members_data WHERE data_gender1='25'"

Where '26' is your database number value for female

"members_data WHERE data_gender1='26'"

3

Re: Total number of Males and Femlas in account Cp stats

seeme thanks
i forgot to add your point 1
i have that done in my instalation...looks like i forgot to mention it
about your number 2
dunno what u mean.
if yours 25 and 26 refer to genders then my code values are like in the database:
1 for male and 2 for female

every member  shjould check wich are the codes for genders and replace those codes with their specific gender codes smile

anyway thanks

4

Re: Total number of Males and Femlas in account Cp stats

Actually, my database gender values are:
'45' = male
'44' = female

I mention it so other members will have an idea what to edit just in case they cannot get your mod to work.

Which by the way, is a copy (off the forum) and paste (in your file) mod.

Again, well done

5

Re: Total number of Males and Femlas in account Cp stats

Hey there, I cannot seem to find:

<td class="gridHeader">{lang:"stats","total_server_messages"}</td>

This is what I have on the bottom:

                    </tr>
                    <tr>
                        <td class="gridHeader">{lang:"stats","messages_stats"}</td>
                        <td class="gridHeader" style="text-align: center">{lang:"stats","read"}</td>
                        <td class="gridHeader" style="text-align: center">{lang:"stats","unread"}</td>
                    </tr>
                    <tr>
                        <td class="gridLabels1">{lang:"stats","total_server_messages"}</td>
                        <td class="gridValue1" style="text-align: center">{total_server_amessages}</td>
                        <td class="gridValue1" style="text-align: center">{total_server_imessages}</td>
                    </tr>
                </table>

6

Re: Total number of Males and Femlas in account Cp stats

Could be that you're using a different version.

7

Re: Total number of Males and Femlas in account Cp stats

I'm using 2.5.3

8

Re: Total number of Males and Femlas in account Cp stats

gstar put it after
<td class="gridValue1" style="text-align: center">{total_server_imessages}</td>
                    </tr>

mine is 2.5.2 so lines might look a little different
thig is all code i added was at the end of all codes so i know that at the end is mine

9

Re: Total number of Males and Femlas in account Cp stats

Hello

What is the mod for 2.5.5?

10

Re: Total number of Males and Femlas in account Cp stats

To make it work with 2.5.5 change all (2) occurrences of members_data to members_data_members

11

Re: Total number of Males and Femlas in account Cp stats

What if we want to advance this method to include a "Browse" page at the navigation? Let's say if we want to set a count of Males & Females with hyperlinks to search for each:

This is what I have so far as browse.tpl:

~Include header stuff ~
    <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                        <td class="gridHeader">Total</td>
                        <td class="gridHeader" style="text-align: center">Men</td>
                        <td class="gridHeader" style="text-align: center">Women</td>

                    </tr>
                    <tr>
                        <td class="gridValue1" style="text-align: center"><a href="{virtual_path}index.php?m=search&issearch=1&gender1=1&gender2=3">{total_men_users}</a></td>
                        <td class="gridValue1" style="text-align: center"><a href="{virtual_path}index.php?m=search&issearch=1&gender1=2&gender2=4">{total_women_users}</a></td>
~Include footer stuff

browse.php:

    //------------------------------------------------
    // Get total members on the server
    //------------------------------------------------

    //Total
        $result = $DB->query("SELECT count(*) as totalmemberst FROM " . DB_PREFIX . "members_data");
        $obj = $DB->fetch_object($result);
        $total_male_users = $obj->totalmembersm ? $obj->totalmemberst : 0;

    // Men
        $result = $DB->query("SELECT count(*) as totalmembersm FROM " . DB_PREFIX . "members_data WHERE data_gender1='1' AND data_gender2='3' ");
        $obj = $DB->fetch_object($result);
        $total_male_users = $obj->totalmembersm ? $obj->totalmembersm : 0;


    // Women
        $result = $DB->query("SELECT count(*) as totalmembersf FROM " . DB_PREFIX . "members_data WHERE data_gender1='2' AND data_gender2='4' ");
        $obj = $DB->fetch_object($result);
        $total_female_users = $obj->totalmembersf ? $obj->totalmembersf : 0;

    //------------------------------------------------
    // Clean up
    //------------------------------------------------
    unset($result);
    unset($obj);

    //------------------------------------------------
    // Assign template vars
    //------------------------------------------------

    $TEMPLATE->assign("total_ausers", $total_ausers);
    $TEMPLATE->assign("total_iusers", $total_iusers);

    $TEMPLATE->assign("total_users", $total_users);
    $TEMPLATE->assign("total_men_users", $total_men_users);
    $TEMPLATE->assign("total_women_users", $total_women_users);
    $TEMPLATE->assign("total_gay_users", $total_gay_users);
    $TEMPLATE->assign("total_lesbian_users", $total_lesbian_users);
    $TEMPLATE->assign("total_couple_users", $total_couple_users);


    return 1;
}
// End Function

?>

However, when I put both files under web root directory and run from a browser, I get a blank page. I know that there must be something like a database connect to make it work. May I ask for your help the rest of the way?

12

Re: Total number of Males and Femlas in account Cp stats

What if Its not just male and females?
What if One has several options? Should it not be dynamic in the sense that it takes the name of field Option instead of hardcoded male and female?

e.g:
we have 100 [males]
we have 100 [females]
we have 100 [couples]
we have 100 [according to field option]

Vlad can you put it in the next upgrade pleasssssssssssseeeeeeeeeeeee. The only files I every change is my template files as I want a hassle free upgrade everytime unless its a template change ;-)

When the next upgrade ?

13

Re: Total number of Males and Femlas in account Cp stats

I try this on my site vld 2.5.3 but it´s not working.
it is someone here who get it working ?

14

Re: Total number of Males and Femlas in account Cp stats

Hi,

well, it's a great feature, but it shows the total members of males and females, with all the "canceled members", and the "pending members".

So How can I do the same thing, but just for the "Regular members" ?

I wanna see the number of Regular males members, and the number of Regular Female members.

Thxs