Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: dobie on August 02, 2009, 07:24:15 PM

Title: Pulling Gender
Post by: dobie on August 02, 2009, 07:24:15 PM
hi i have this problem i cannot get gender to show elsewhere i have this at moment

require_once("../ccn/SSI.php");

global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;
if (!$context['user']['is_guest']) {
             // gets just the users id
             $id = $user_info['id'];
             // gets the entire link: e.g. (for Admin would output) http://xxxxx.xxxx/index.php?action=profile;u=1
             $ahrefLink = $scripturl . '?action=profile;u=';
   // Get username as a link to their profile automatically, from id...
   ssi_fetchMember($user_info['id']['gender']);
loadMemberContext($userid);


then im calling it like this so members will be shown as male or female

$memberContext[$user_info['id']]['gender']['name'];

but this does not work so i am happy if someone can point me in right direction

thanx
Title: Re: Pulling Gender
Post by: JBlaze on August 03, 2009, 03:04:43 AM
<?phprequire_once("../ccn/SSI.php");function get_memberData(){    global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;        if (!$context['user']['is_guest'])        $member = array();        $request = $smcFunc['db_query']('', '          SELECT id_member, real_name, gender          FROM {db_prefix}members          WHERE id_member = {int:id_member}',          array(            'id_member' => $user_info['id'],          )        );        $smcFunc['db_free_result']($request);        if (isset($user_info['id']))        return $member;    while ($row = $smcFunc['db_fetch_assoc']($request))    {        $member = array(          'id' => $row['id_member'],          'name' => array(            'text' => $row['real_name'],            'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="View the profile of ' . $row['real_name'] . '">' . $row['real_name'] . '</a>',            'href' => $scripturl . '?action=profile;u=' . $row['id_member'],          ),          'gender' => array(            'text' => $row['gender'],            'image' => '<img src="' . $settings['images_url'] . '/' . $row['gender'] . '.gif" alt="' . $row['gender'] . '" />',          ),        );     }}// output the data$members = get_memberData();foreach ($members as $member){  echo ' '; // Put your data strings here// $member['id']// $member['name']['text'], $member['name']['link'], $member['name']['href']// $member['gender']['text'], $member['gender']['image']}?>

This is a bit more than just calling $context variables, but is more flexible for what you need.
Title: Re: Pulling Gender
Post by: tyty1234 on August 03, 2009, 03:58:56 AM
Sadly JBlaze, your function didn't work for me. :P

So, I turned your function into an easier one, without the db_queries. :P


<?phprequire(dirname(__FILE__) . '/ccn/SSI.php');function get_memberData(){ global $context, $user_info, $memberContext; // Only show the data if they are a member. if (!$context['user']['is_guest']) { // Load everything needed to get the gender. Basically, load their whole profile. loadMemberData($user_info['id'], false, 'profile'); loadMemberContext($context['user']['id']); $context['member'] = $memberContext[$context['user']['id']]; // Put the data into an array. foreach($context['member'] as $key => $value) { $member[$key] = $value; } // Return the data. return $member; } else { $member = array(); return $member; }}// Put the data into ths variable.$memberData = get_memberData();echo $memberData['gender']['name'] . '&nbsp;' . $memberData['gender']['image'];/* You can get more data from here. Here are some examples.$memberData['name'] (for member name)$memberData['id'] (for member id)$memberData['link'] (link to member profile)*/?>
Title: Re: Pulling Gender
Post by: JBlaze on August 03, 2009, 04:01:27 AM
Meh fair enough. That's what happens when you rip from your own code and *think* it'll work...

Nice job tyty :)
Title: Re: Pulling Gender
Post by: tyty1234 on August 03, 2009, 04:26:26 AM
haha, thanks. :D
Title: Re: Pulling Gender
Post by: dobie on August 05, 2009, 03:47:17 AM
thanx to both  sadly it dont work for me i am trying to pull gender from database which in turns gives a my users a male ot female  icon im soooooooooooooo lost any help would be appreciated
Title: Re: Pulling Gender
Post by: tyty1234 on August 05, 2009, 04:41:21 AM
did you try my script? or JBlaze's?
Title: Re: Pulling Gender
Post by: dobie on August 05, 2009, 05:17:06 AM
i tried yours tyty and blazes what i have got is avchat3.0 chat system and what im after is the gender part of intergration to be picked up so a woman will be shown as a female icon and male etc this is what i have at moment

<?php require_once("../ccn/SSI.php"); global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;if (!$context['user']['is_guest']) {             // gets just the users id             $id = $user_info['id'];             // gets the entire link: e.g. (for Admin would output) http://xxx.xxxxx.com/index.php?action=profile;u=1             $ahrefLink = $scripturl . '?action=profile;u=';   // Get username as a link to their profile automatically, from id...   ssi_fetchMember($user_info['id']['gender']);}
Title: Re: Pulling Gender
Post by: tyty1234 on August 05, 2009, 10:48:32 PM
are you trying to include the gender on the chat page, or are trying to pull the gender from the chat system?
Title: Re: Pulling Gender
Post by: dobie on August 06, 2009, 12:29:26 AM
hi tyty i am trying to pull the gender from chat as its has male and female but i want to use my users gender from smf

i have a xml code <xliff version="1.0" xml:lang="en">

  <file datatype="plaintext" original="videorecorder.fla" source-language="EN">
    <header></header>
    <body>
      <trans-unit id="000" resname="IDS_BT_CLOSE">
        <source>Close</source>
      </trans-unit>
      <trans-unit id="000a" resname="IDS_BT_CANCEL">
        <source>Cancel</source>
      </trans-unit>
      <trans-unit id="001" resname="IDS_MALE">
        <source>Male</source>
      </trans-unit>
      <trans-unit id="002" resname="IDS_FEMALE">
        <source>Female</source>
      </trans-unit>
      <trans-unit id="003" resname="IDS_COUPLE">
        <source>Couple</source>


i have users profile working correctly but i just cant get this male and female icon in chat

dobie
Title: Re: Pulling Gender
Post by: N3RVE on August 13, 2009, 09:36:13 AM
Do you require any further support?
I'll move this to a more appropriate section where it will get the attention it deserves :).

-[n3rve]