Top Members Block

Hello,

 

I want use default Boonex members block on home page only for Top section.

Can someone provide me php content of the block?

 

http://demo.boonex.com/index.php?MembersMode=top

 

 

Thanks,

top rated members block.jpg · 11.9K · 897 views
Quote · 5 Jan 2013

i have needed a Members block like default Boonex Member block, but i want showing only "Top" section.

I do not want other section in the Block like "Latest" and "Online"

Quote · 5 Jan 2013

Do you want to modify the existing member block? or keep the existing and create new one of just top members?

https://www.deanbassett.com
Quote · 5 Jan 2013

 

Do you want to modify the existing member block? or keep the existing and create new one of just top members?

 I want create new one on homepage.

Quote · 5 Jan 2013

I was afraid you were going to say that.

That ones a bit more complex. I will have to think on that one. It will take far more free time than i have right now. This won't be a few simple lines of php code.

https://www.deanbassett.com
Quote · 5 Jan 2013

 

I was afraid you were going to say that.

That ones a bit more complex. I will have to think on that one. It will take far more free time than i have right now. This won't be a few simple lines of php code.

 Ya, i understand you.

Quote · 5 Jan 2013

Ok. As you requested in a message. This code should display the first 10 of the top members. Place in a PHP block. I have also attached as a file just incase the forum damages the code.

    $aDefFields = array(
        'ID', 'NickName', 'Couple', 'Sex'
    );
    $sCode = '';

    $iOnlineTime = (int)getParam( "member_online_time" );

    //main fields
    $sqlMainFields = "";
    foreach ($aDefFields as $iKey => $sValue)
         $sqlMainFields .= "`Profiles`. `$sValue`, ";

    $sqlMainFields .= "if(`DateLastNav` > SUBDATE(NOW(), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`";

    // possible conditions
    $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)";
    $aParams = array();
    if (is_array($aParams)) {
         foreach ($aParams as $sField => $sValue)
             $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";
    }

    $sqlOrder = "";

    $oVotingView = new BxTemplVotingView ('profile', 0, 0);
    $aSql        = $oVotingView->getSqlParts('`Profiles`', '`ID`');
    $sqlOrder    = $oVotingView->isEnabled() ? " ORDER BY `Profiles`.`Couple` ASC, (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `Profiles`.`DateReg` DESC" : $sqlOrder;
    $sqlMainFields .= $aSql['fields'];
    $sqlLJoin    = $aSql['join'];
    $sqlCondition .= " AND `pr_rating_count` > 1";


    if (empty($sqlLJoin)) $sqlLJoin = '';
    $iCount = (int)db_value("SELECT COUNT(`Profiles`.`ID`) FROM `Profiles` $sqlLJoin $sqlCondition");
    $aData = array();


    $sqlQuery = "SELECT " . $sqlMainFields . " FROM `Profiles` $sqlLJoin $sqlCondition $sqlOrder LIMIT 10";
    $rData = db_res($sqlQuery);
    if ($iCount) {
        $aOnline = $aTmplVars = array();
        while ($aData = mysql_fetch_assoc($rData)) {
            $aOnline['is_online'] = $aData['is_online'];
            $aTmplVars[] = array(
                'thumbnail' => get_member_thumbnail($aData['ID'], 'none', true, 'visitor', $aOnline)
            );
        }
        $sCode = $GLOBALS['oSysTemplate']->parseHtmlByName('members_list.html', array(
            'bx_repeat:list' => $aTmplVars
        ));

    } else {
        $sCode = MsgBox(_t("_Empty"));
    }
    echo $sCode;

top 10.php · 1.9K · 305 downloads
https://www.deanbassett.com
Quote · 6 Jan 2013

Thank you for your help. Its working fine!

Quote · 6 Jan 2013

 

Ok. As you requested in a message. This code should display the first 10 of the top members. Place in a PHP block. I have also attached as a file just incase the forum damages the code.

    $aDefFields = array(
        'ID', 'NickName', 'Couple', 'Sex'
    );
    $sCode = '';

    $iOnlineTime = (int)getParam( "member_online_time" );

    //main fields
    $sqlMainFields = "";
    foreach ($aDefFields as $iKey => $sValue)
         $sqlMainFields .= "`Profiles`. `$sValue`, ";

    $sqlMainFields .= "if(`DateLastNav` > SUBDATE(NOW(), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`";

    // possible conditions
    $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)";
    $aParams = array();
    if (is_array($aParams)) {
         foreach ($aParams as $sField => $sValue)
             $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";
    }

    $sqlOrder = "";

    $oVotingView = new BxTemplVotingView ('profile', 0, 0);
    $aSql        = $oVotingView->getSqlParts('`Profiles`', '`ID`');
    $sqlOrder    = $oVotingView->isEnabled() ? " ORDER BY `Profiles`.`Couple` ASC, (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `Profiles`.`DateReg` DESC" : $sqlOrder;
    $sqlMainFields .= $aSql['fields'];
    $sqlLJoin    = $aSql['join'];
    $sqlCondition .= " AND `pr_rating_count` > 1";


    if (empty($sqlLJoin)) $sqlLJoin = '';
    $iCount = (int)db_value("SELECT COUNT(`Profiles`.`ID`) FROM `Profiles` $sqlLJoin $sqlCondition");
    $aData = array();


    $sqlQuery = "SELECT " . $sqlMainFields . " FROM `Profiles` $sqlLJoin $sqlCondition $sqlOrder LIMIT 10";
    $rData = db_res($sqlQuery);
    if ($iCount) {
        $aOnline = $aTmplVars = array();
        while ($aData = mysql_fetch_assoc($rData)) {
            $aOnline['is_online'] = $aData['is_online'];
            $aTmplVars[] = array(
                'thumbnail' => get_member_thumbnail($aData['ID'], 'none', true, 'visitor', $aOnline)
            );
        }
        $sCode = $GLOBALS['oSysTemplate']->parseHtmlByName('members_list.html', array(
            'bx_repeat:list' => $aTmplVars
        ));

    } else {
        $sCode = MsgBox(_t("_Empty"));
    }
    echo $sCode;

 

Not to sound like a retard, but I do have to install the option to have a php block in the 7.10 version before using your code correct?

Quote · 12 Jan 2013

Yes. A php block is needed for this. So some way to do php blocks will be needed.

You can add it to page builders with this. http://www.boonex.com/m/Add_PHP_Block_to_Page_Builders_

Or either of these can insert and edit php blocks without changing dolphins code.

http://www.boonex.com/m/Block_Tools

http://www.boonex.com/m/Deanos_Tools_V1_6_Dolphin_7_0_Version

https://www.deanbassett.com
Quote · 13 Jan 2013

Thanks deano92964!

Quote · 13 Jan 2013

Thanks deano92964 it is very useful!

I make a little modification to show only the online members and to female members shows the male members and for male shows the female members and all that displays randomly.

Replace this in deano92964's code

// possible conditions
    $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)";
    $aParams = array();
    if (is_array($aParams)) {
         foreach ($aParams as $sField => $sValue)
             $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";
    }

    $sqlOrder = "";

    $oVotingView = new BxTemplVotingView ('profile', 0, 0);
    $aSql        = $oVotingView->getSqlParts('`Profiles`', '`ID`');
    $sqlOrder    = $oVotingView->isEnabled() ? " ORDER BY `Profiles`.`Couple` ASC, (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `Profiles`.`DateReg` DESC" : $sqlOrder;
    $sqlMainFields .= $aSql['fields'];
    $sqlLJoin    = $aSql['join'];
    $sqlCondition .= " AND `pr_rating_count` > 1";


with this:

$userinf = getProfileInfo($userid); ///add to the beginning of the code

$usersex = $userinf['Sex']; ///add to the beginning of the code


$sqlOrder = "";


if($usersex == "female"){

    // possible conditions

    $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`) and ( `Profiles`.`Sex` = 'male')";

    $aParams = array();

    if (is_array($aParams)) {

         foreach ($aParams as $sField => $sValue)

             $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";

    }


$sqlCondition .= " AND `Profiles`.`DateLastNav` > SUBDATE(NOW(), INTERVAL ".$iOnlineTime." MINUTE)";

                        $sqlOrder = " ORDER BY RAND()";}


else{

    // possible conditions

    $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`) and ( `Profiles`.`Sex` = 'female')";

    $aParams = array();

    if (is_array($aParams)) {

         foreach ($aParams as $sField => $sValue)

             $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";

    }

I have attached the full code.

I am not a PHP developer, so the code are not perfect, but works.

I like to improve the online members section with auto refresh function. I tried this header('Refresh: 5');  but this reload the whole page.

Have someone an idea how to refresh only the php block? The best solution will be to refresh the members inside the php block (online members) one to one. Every 10-15s replace only one member with a new one and in the next 10-15s replace a next member and so on.

Can someone have any idea or suggestion how to realize this? Maybe some code examples.

Sorry for my bad english.

online_members.txt · 2.4K · 356 downloads
Quote · 8 Feb 2013

I posted this a few days ago about a similar scenario. Deanos could you check it out please. http://www.boonex.com/forums/?action=goto&my_threads=1#topic/Adding-custom-popups-and-links-to-box-header.htm

caredesign.net
Quote · 8 Feb 2013

Can someone help me modify this code to show the users City or some other field from their profile?

You have this list of top members, but it just shows their name. I would like it to show their name and, if possible, on the next line down, their city...

Actually, I would like to make an if-then statement based on their profile type from Anton's Profile Splitter, but if I could just see a simple example of adding their city, I could modify it to suit my needs.

Thanks...

Quote · 20 Jul 2013

$aDefFields = array(
        'ID', 'NickName', 'Couple', 'Sex'
    );

Add the fields from the Profiles table you wish to be included.

Geeks, making the world a better place
Quote · 20 Jul 2013

Kinda,

I would add the fields there, but how do you get them to display? At the moment, even though "Sex" is already included, only the username is displayed...

I was thinking somewhere in this section?

        $sCode = $GLOBALS['oSysTemplate']->parseHtmlByName('members_list.html', array(
            'bx_repeat:list' => $aTmplVars
        ));

Maybe I have to edit members_list.html?

Quote · 20 Jul 2013

Your close, but you can't from any of that code.

The code your looking at passes the $aTmplVars to the template parser function that uses members_list.html

The function that is called here.

            $aTmplVars[] = array(
                'thumbnail' => get_member_thumbnail($aData['ID'], 'none', true, 'visitor', $aOnline)
            );

That loads the $aTmplVars array is get_member_thumbnail which is what generates the code that shows the pic with the name. That function is built into dolphin and it is that function along with the template that has to be changed.

So there is nothing with this script itself that you can change that will do what you need. To keep the changes you want separate from dolphins other blocks that generate a thumbnail block you would need to write a replacement for get_member_thumbnail to be used here and a new members_list.html.

Sorry. Not as easy as you may have hoped for.


https://www.deanbassett.com
Quote · 20 Jul 2013
 
 
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.