Battle of the Sexes

Mod that adds a extra field to the users profile, the gender is displayed beside the posts

Moderator: Moderators

Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

Battle of the Sexes

Postby Moustacy on Thu 03. Jun, 2004 20:27

I installed the gender mod and that's all fine and well but I wanted to have on the main page the number of male members and female members so I used this

Code: Select all
##############################################################
## MOD Title: No of Female and Male Members on Index
## MOD Author: Dioxins < dioxins@yahoo.com >
## Special thanks to dannic06 < http://www.phpbb.com/phpBB/profile.php?mode=viewprofile&u=68228 >
##
## MOD Description: This mod will allow users to see the number of female and male registrants
## in the index
## MOD Version: 1.1
##
## Installation Level: Easy
## Installation Time: ~3 Minutes
## Files To Edit: 4
##         language/lang_xxx/lang_main.php
##         includes/functions.php
##         index.php
##         templates/xxx/index_body.tpl
## Files Included: none
##
##
##############################################################
##
## Changes
## MOD Version 1.1 Typo Error
##  $total_male = get_db_stats('gender-male'); instead of
##  $total_male = get_db_stat('gender-male');
##
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## Requires Gender Mod by Niels Chr Rød. Denmark < ncr@db9.dk >
## Tested on 2.0.4 and without problems.
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
# (make sure to edit this file for every language your board uses).

language/lang_xxx/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
#

$lang['Registered_user_total'] = 'We have <b>%d</b> registered user';

#
#-----[ AFTER ADD]------------------------------------------
#

$lang['male_zero_total'] = 'We have <b>0</b> Male Member'; // # registered male users
$lang['male_total'] = 'We have <b>%d</b> Male Members'; // # registered male users
$lang['male_one_total'] = 'We have <b>%d</b> Male Member'; // # registered male users
$lang['female_zero_total'] = 'We have <b>0</b> Female Member'; // # registered female users
$lang['female_total'] = 'We have <b>%d</b> Female Members'; // # registered female users
$lang['female_one_total'] = 'We have <b>%d</b> Female Member'; // # registered female users

#
#-----[ OPEN ]------------------------------------------
#

includes/functions.php

#
#-----[ FIND ]------------------------------------------
#

       case 'newestuser':
            $sql = "SELECT user_id, username
                FROM " . USERS_TABLE . "
                WHERE user_id <> " . ANONYMOUS . "
                ORDER BY user_id DESC
                LIMIT 1";
            break;

#
#-----[ AFTER ADD]------------------------------------------
#

        case 'gender-male':
            $sql = "SELECT COUNT(user_id) AS total_male
                FROM " . USERS_TABLE . "
                WHERE user_gender = '1'";
            break;
        case 'gender-female':
            $sql = "SELECT COUNT(user_id) AS total_female
                FROM " . USERS_TABLE . "
                WHERE user_gender = '2'";
            break;

#
#-----[ FIND ]------------------------------------------
#

        case 'topiccount':
            return $row['topic_total'];
            break;

#
#-----[ AFTER ADD]------------------------------------------
#

        case 'gender-male':
            return $row['total_male'];
            break;
        case 'gender-female':
            return $row['total_female'];
            break;
           
#
#-----[ OPEN ]------------------------------------------
#

index.php

#
#-----[ FIND ]------------------------------------------
#

$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');

#
#-----[ AFTER ADD]------------------------------------------
#

$total_male = get_db_stat('gender-male');
$total_female = get_db_stat('gender-female');

#
#-----[ FIND ]------------------------------------------
#

if( $total_users == 0 )
{
   $l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
   $l_total_user_s = $lang['Registered_user_total'];
}
else
{
   $l_total_user_s = $lang['Registered_users_total'];
}

#
#-----[ AFTER ADD]------------------------------------------
#

if( $total_male == 0 )
{
   $l_total_male = $lang['male_zero_total'];
}
else if( $total_male == 1 )
{
   $l_total_male = $lang['male_one_total'];
}
else
{
   $l_total_male = $lang['male_total'];
}

if( $total_female == 0 )
{
   $l_total_female = $lang['female_zero_total'];
}
else if( $total_female == 1 )
{
   $l_total_female = $lang['female_one_total'];
}
else
{
   $l_total_female = $lang['female_total'];
}

#
#-----[ FIND ]------------------------------------------
#

'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),

#
#-----[ AFTER ADD]------------------------------------------
#

'TOTAL_MALE' => sprintf($l_total_male, $total_male),
'TOTAL_FEMALE' => sprintf($l_total_female, $total_female),

#
#-----[ OPEN ]------------------------------------------
#

templates/xxx/index_body.tpl

#
#-----[ FIND ]------------------------------------------
#

{TOTAL_USERS}<br />{NEWEST_USER}

#
#-----[ AFTER, ADD ]------------------------------------------
#

<br /><br /><b>Battle of the Sexes</b><br /><br />{TOTAL_FEMALE}<br />{TOTAL_MALE}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------- -----
#
# EoM



And on my board both male and female say 0 and its not putting the numbers so I'm trying to figure out what the problem could be. I have phpbb 2.0.6 and its located here http://forum.moustacy.com if anyone could help I would appreciate it.
Moustacy
Poster
Poster
 
Posts: 15
Joined: Wed 04. Feb, 2004 05:04

Postby gurlzlubme on Mon 29. Nov, 2004 22:48

I'm having the same problem. Both male and female stats show a 0.



phpbb2 2.0.11
gurlzlubme
Poster
Poster
 
Posts: 29
Joined: Wed 03. Nov, 2004 07:10

Postby gurlzlubme on Sun 05. Dec, 2004 13:23

Moustacy, check your functions.php again. You might have made the same mistake as I did, which is adding

Code: Select all
case 'gender-male':
            return $row['total_male'];
            break;
        case 'gender-female':
            return $row['total_female'];
            break;


under the wrong case 'topiccount':


I corrected mine, and so it works now. :oops:
gurlzlubme
Poster
Poster
 
Posts: 29
Joined: Wed 03. Nov, 2004 07:10


Return to Gender [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron