Help adding fields to Geeky Admin menu

I am trying to add a menu item the Geeky menu.  I tried to follow the instructions below for adding an ID number.  This only worked for ID.  When I tried to add different items (sex, city, etc.) it didn't work.  Can someone please explain why and what I must do to make it work.

Thanks!

 

 

In the following files :

administration/templates/base/mp_members_simple.html
administration/templates/base/mp_members_extended.html
administration/templates/base/mp_members_geeky.html

Find :

__username__

Replace with :

__username__ (__id__)

Quote · 28 Sep 2010

__id__ is a template key. Keys are replaced when the template is parsed. So adding keys that have not been defined in the code that parses the template will not work. So the needed keys need to be defined in code with data extracted from the database.

So in addition to the template changes to add the key where you want it to appear such as __sex__

You would need to define it.

I will cover one function. This is for the geeky member display.

administration/profiles.php at around line 425 is this function.

function getMembersGeeky($aProfiles, $sPaginate) {
$iEmailLength = 20;
$aItems = array();
foreach($aProfiles as $aProfile){
$sEmail = ( mb_strlen($aProfile['email']) > $iEmailLength ) ? mb_substr($aProfile['email'], 0, $iEmailLength) . '...' : $aProfile['email'];

$aItems[$aProfile['id']] = array(
'id' => $aProfile['id'],
'username' => $aProfile['username'],
'email' => $sEmail,
'full_email' => $aProfile['email'],
'edit_link' => $GLOBALS['site']['url'] . 'pedit.php?ID=' . $aProfile['id'],
'edit_class' => (int)$aProfile['banned'] == 1 ? 'adm-mp-banned' : ($aProfile['status'] != 'Active' ? 'adm-mp-inactive' : 'adm-mp-active'),
'registration' => $aProfile['registration'],
'last_login' => $aProfile['last_login'],           
'status' => $aProfile['status'],
'ml_id' => !empty($aProfile['ml_id']) ? (int)$aProfile['ml_id'] : 2,
'ml_name' => !empty($aProfile['ml_name']) ? $aProfile['ml_name'] : 'Standard'
);
}


This is where all the keys that are passed to the template are defined.

You would need to add the one you want like so.

function getMembersGeeky($aProfiles, $sPaginate) {
$iEmailLength = 20;
$aItems = array();
foreach($aProfiles as $aProfile){
$sEmail = ( mb_strlen($aProfile['email']) > $iEmailLength ) ? mb_substr($aProfile['email'], 0, $iEmailLength) . '...' : $aProfile['email'];

$aItems[$aProfile['id']] = array(
'id' => $aProfile['id'],
'username' => $aProfile['username'],
'email' => $sEmail,
'full_email' => $aProfile['email'],
'edit_link' => $GLOBALS['site']['url'] . 'pedit.php?ID=' . $aProfile['id'],
'edit_class' => (int)$aProfile['banned'] == 1 ? 'adm-mp-banned' : ($aProfile['status'] != 'Active' ? 'adm-mp-inactive' : 'adm-mp-active'),
'registration' => $aProfile['registration'],
'last_login' => $aProfile['last_login'],
'sex' => $aProfile['sex'],
'status' => $aProfile['status'],
'ml_id' => !empty($aProfile['ml_id']) ? (int)$aProfile['ml_id'] : 2,
'ml_name' => !empty($aProfile['ml_name']) ? $aProfile['ml_name'] : 'Standard'
);
}


Then above that query that obtains the data from the database. At about line 390 is this.

$sQuery = "
SELECT
`tp`.`ID` as `id`,
`tp`.`NickName` AS `username`,
`tp`.`Headline` AS `headline`,
`tp`.`Sex` AS `sex`,
`tp`.`DateOfBirth` AS `date_of_birth`,
`tp`.`Country` AS `country`,
`tp`.`City` AS `city`,
`tp`.`DescriptionMe` AS `description`,
`tp`.`Email` AS `email`,
DATE_FORMAT(`tp`.`DateReg`,  '" . $sDateFormat . "' ) AS `registration`,
DATE_FORMAT(`tp`.`DateLastLogin`,  '" . $sDateFormat . "' ) AS `last_login`,
`tp`.`Status` AS `status`,
IF(`tbl`.`Time`='0' OR DATE_ADD(`tbl`.`DateTime`, INTERVAL `tbl`.`Time` HOUR)>NOW(), 1, 0) AS `banned`,
`tl`.`ID` AS `ml_id`,
IF(ISNULL(`tl`.`Name`),'', `tl`.`Name`) AS `ml_name`
" . $sSelectClause . "
FROM `Profiles` AS `tp`
LEFT JOIN `sys_admin_ban_list` AS `tbl` ON `tp`.`ID`=`tbl`.`ProfID`
LEFT JOIN `sys_acl_levels_members` AS `tlm` ON `tp`.`ID`=`tlm`.`IDMember` AND `tlm`.`DateStarts` < NOW() AND (`tlm`.`DateExpires`>NOW() || ISNULL(`tlm`.`DateExpires`)) 
LEFT JOIN `sys_acl_levels` AS `tl` ON `tlm`.`IDLevel`=`tl`.`ID`
" . $sJoinClause . "
WHERE
1 AND (`tp`.`Couple`=0 OR `tp`.`Couple`>`tp`.`ID`)" . $sWhereClause . "
" . $sGroupClause . "
ORDER BY `tp`.`" . $aParams['view_order'] . "` " . $aParams['view_order_way'] . "
LIMIT " . $aParams['view_start'] . ", " . $aParams['view_per_page'];
$aProfiles = $GLOBALS['MySQL']->getAll($sQuery);


You need to make sure the field you want is in the query.

For the case of sex, it already is as shown above. But if you needed to include a field that is not in the query then it would need to be added to make the data available to the functions that need it.



Unfortunatly this is not as easy as you might like it to be.

https://www.deanbassett.com
Quote · 28 Sep 2010

Thank you very much for the clear answer.

 

I had implemented the same solution before posting it in the forum, however it didn't work for me.  I tried it with sex, city, and also with a profile field I added through the Nav Menu Builder.

 

Any thoughts?

Quote · 28 Sep 2010

This will have to wait until i have time to run tests. The solution looks sound, but i guess i will have to test it.

https://www.deanbassett.com
Quote · 28 Sep 2010

Okay, thanks for your help!

Quote · 28 Sep 2010

I just tested this

For a quick test after making the code change to add sex to the fields passed to the template i replaced __last_login__ in the template with __sex__ and it worked perfectly.

I did however have to empty the cache folder to see the changes. Which is a common need anyway.

But it does work.



https://www.deanbassett.com
Quote · 28 Sep 2010

Thanks for your help Deano. I had been clearing the cache but couldn't get anywhere so I uploaded fresh files and it finally worked,  just as you said.

 

For anyone else looking to do this, if you want to add the new field you are displaying to the drop-down menu to sort by it, you must alter administation/templates/base/mp_members.php

 

Look for this code:

 

<select name="order_by" class="form_input_select" onchange="__change_order__">

<option value="" selected="selected"><bx_text:_adm_txt_mp_order_none /></option>

<option value="NickName"><bx_text:_adm_txt_mp_order_user_name /></option>

<option value="Database field"><bx_text:language file name /></option>


Quote · 28 Sep 2010
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.