Chucks Extended Profile

17 years 3 months ago #25991 by chucktrukk
Chucks Extended Profile was created by chucktrukk
This has not been tested on 1.02 yet

I have created a new function for an extended userProfile. It made it more easy for me to make the profile look anyway I wish.

What it does:
It loads all of the users information into variables such as
- $user->registerDate
- $user->hits

and allows you to place tabs wherever you want such as
- $userViewTabs["cb_tabmain"];
- $userViewTabs["cb_middle"];

How to use it:
  1. Create a backup copy of comprofiler.php
  2. Create a backup copy of comprofiler.html.php
  3. In comprofiler.php, replace HTML_comprofiler::userProfile with:
    [code:1]HTML_comprofiler::«»xtdUserProfile( $user, $option, $submitvalue, $my);[/code:1]
  4. Add a new function in comprofiler.html.php called xtdUserProfile (after or before function userProfile. Paste the following code)
    [code:1]function xtdUserProfile($user, $option,$submitvalue) {

    global $database,$my,$ueConfig,$_REQUEST,$_POST,$_PLUGINS, $mainframe;



    $_PLUGINS->loadPluginGroup('user');

    $results = $_PLUGINS->trigger( 'onBeforeUserProfileRequest', array(&$user,1));

    if ($_PLUGINS->is_errors()) {

    echo "<script type=\"text/javascript\">alert(\"".$_PLUGINS->getErrorMSG()."\"«»); window.history.go(-1); </script>_CRLF_";

    exit();

    }



    $cbMyIsModerator = isModerator($my->id);

    $cbUserIsModerator = isModerator($user->id);



    $showProfile=1;

    if ($user->banned != 0 || ($user->block == 1 && $user->confirmed && $user->approved)) {

    echo "<font color=red>"._UE_USERPROFILEBANNED;

    if($my->id != $user->id && $cbMyIsModerator != 1) {

    $showProfile=0;

    } else {

    if ($user->block == 1) {

    echo ": "._LOGIN_BLOCKED;

    }

    if ($user->banned != 0) {

    echo "<br />".nl2br($user->bannedreason);

    }

    }

    echo "<br /></font>";

    }

    if (!$user->confirmed) echo "<font color=red>"._UE_USER_NOT_CONFIRMED."</font><br />";

    if (!$user->approved) echo "<font color=red>"._UE_USER_NOT_APPROVED."</font><br />";

    if ((!$user->confirmed || !$user->approved) && $cbMyIsModerator!=1) {

    $showProfile=0;

    }

    if ($showProfile==1) {

    if ( method_exists($mainframe,"setPageTitle"«»)) {

    $mainframe->setPageTitle( unHtmlspecialchars(getNameFormat($user->name,$user->username,$ueConfig)));

    }

    if ( method_exists($mainframe,"appendPathWay"«»)) {

    $mainframe->appendPathWay( getNameFormat($user->name,$user->username,$ueConfig));

    }

    $i=1;

    outputCbTemplate(1);

    echo initToolTip(1);

    ?>

    <script type="text/javascript">

    function cbConnSubmReq() {

    cClick();

    document.connOverForm.submit();

    }

    function confirmSubmit() {

    if (confirm("<?php echo _UE_CONFIRMREMOVECONNECTION; ?>"«»))

    return true ;

    else

    return false ;

    }

    </script>

    <?php

    $results = $_PLUGINS->trigger( 'onBeforeUserProfileDisplay', array(&$user,1,&$cbUserIsModerator,&$cbMyIsModerator)); //$ui=1 //BBB: params?

    if ($_PLUGINS->is_errors()) {

    echo "<script type=\"text/javascript\">alert(\"".$_PLUGINS->getErrorMSG()."\"«»); window.history.go(-1); </script>_CRLF_";

    exit();

    }

    if (is_array($results)) {

    for ($i=0, $n=count($results); $i<$n; $i++) {

    echo $results[$i];

    }

    }



    $tabs = new cbTabs( 0, 1 );

    $userViewTabs = $tabs->getViewTabs($user); // this loads, registers menu and user status and renders the tabs



    require_once ($mosConfig_absolute_path . 'components/com_comprofiler/xtd_views/xtdUserProfile.php');



    $tab = null;

    if (isset($_GET)) $tab = urldecode($_GET);

    elseif (isset($_POST)) $tab = $_POST;

    if ($tab) echo "<script type=\"text/javascript\">showCBTab('".addslashes(htmlspecialchars($tab))."');</script>_CRLF_";



    if($my->id!=$user->id) {

    recordViewHit($my->id,$user->id,getenv('REMOTE_ADDR'));

    }

    $_PLUGINS->trigger( 'onAfterUserProfileDisplay', array($user,true));

    }

    }[/code:1]
  5. Create a folder components/com_comprofiler/xtd_views
  6. Create a file in that folder called xtdUserProfile.php
  7. Paste this code in xtdUserProfile.php
    [code:1]<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

    $avatar = $user->avatar;
    $avatarapproved = $user->avatarapproved;

    if ($avatar=='' || $avatar==null) {
    //$avatar_img = "components/com_comprofiler/plugin/language/default_language/images/tnnophoto.jpg";
    $avatar_img = sefRelToAbs( 'components/com_comprofiler/plugin/language/default_language/images/nophoto.jpg' );
    } elseif ($avatarapproved==0) {
    $avatar_img = sefRelToAbs( 'components/com_comprofiler/plugin/language/default_language/images/tnpendphoto.jpg' );
    } elseif (strpos($avatar,"gallery/"«»)===false) {
    $avatar_img = "images/comprofiler/tn".$avatar;
    } else {
    $avatar_img = sefRelToAbs( 'images/comprofiler/' .$avatar );
    }

    if($ueConfig==1) {
    $database->setQuery("SELECT COUNT(*) FROM #__session WHERE userid =".$user->id);

    $isonline = $database->loadResult();
    $online_status = '';
    if ($isonline > 0) {
    $online_status = 'Online';
    } else {
    $online_status = 'Offline';
    }
    }

    //Date Functions
    if ($user->lastupdatedate == '0000-00-00 00:00:00') {
    $user->lastupdatedate = 'Never';
    } else {
    $user->lastupdatedate = cbFormatDate($user->lastupdatedate);
    }

    $user->registerDate = cbFormatDate($user->registerDate);
    $user->lastvisitDate = cbFormatDate($user->lastvisitDate);

    ?>
    <!-- Begin xtdUserProfile Template -->

    <table cellpadding="0" cellspacing="0" border="0" width="540">
    <tr>
    <td>
    <div style="float:left; width:150px; height:209px; margin: 0 10px 5px 10px; text-align:center;"><img src="<?php echo $avatar_img; ?>" title="Your Avatar" alt="Your Avatar" /></div>
    <div style="float:right; width:103px; margin: 0 10px 0 10px;">
    <a href="<?php echo sefRelToAbs( 'index.php?option=com_comprofiler&task=usersList' ); ?>" title="The Community">
    </a>
    </div>
    <p><?php echo $user->username; ?>'s Profile</p>
    <p><strong>Hits:</strong> <?php echo $user->hits; ?><br/>
    <strong>Online Status:</strong> <?php echo $online_status; ?><br/>
    <strong>Member Since:</strong> <?php echo $user->registerDate; ?><br/>
    <strong>Last Online:</strong> <?php echo $user->lastvisitDate; ?><br/>
    <strong>Last Updated:</strong> <?php echo $user->lastupdatedate; ?><br/>
    <br/><?php echo $userViewTabs["cb_head"]; ?></p>
    </td>
    </tr>
    <tr>
    <td><br/>
    <?php echo $userViewTabs["cb_tabmain"]; ?><br/>
    <?php echo $userViewTabs["cb_underall"]; ?><br/>
    <?php echo $userViewTabs["cb_middle"]; ?>
    </td>
    </tr>
    </table>
    <!-- End xtdUserProfile Template -->[/code:1]
  8. Lastly, edit the HTML that follows '<!-- Begin xtdUserProfile Template -->

Note 1: You may or may not want to use want to use the Dateformat, avatar, and online status code in xtdUserProfile.php. You can remove this if you would like.

Chuck

PS - I make no warranties and am not held liable with anything this code does for or against you. It is released as GNU GPL.

Please Log in to join the conversation.

17 years 3 months ago #25993 by chucktrukk
Replied by chucktrukk on topic Re:Chucks Extended Profile
radio,

You can create a profile like www.mingleville.com/xL15Ax? with something like the following:

[code:1]
<table class="xtdUserProfileWrapper">
<tr>
<td colspan="2">
Header here - Register, login links here
</td>
</tr>
<tr>
<td colspan="2">
<!-- Top row of links -->
<?php echo $userViewTabs["cb_head"]; ?>
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
Rating<br/> <em>I never figured how to get the rating to work correctly</em>
</div>
<!-- Your Avatar -->
<img src="<?php echo $avatar_img; ?>" title="Your Avatar" alt="Your Avatar" align="left" />
<?php echo $user->username; ?>
<br/>
Name: <?php echo $user->firstname; ?>
Age: <?php echo $user->age; ?>
Gender: <?php echo $user->gender; ?>
<br/>
Town/City: <?php echo $user->city; ?>
Country: <?php echo $user->country; ?>
<br/>
Links here, such as: Send a Message, Donate Points , Add to Buddy List, Add to Block List
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
This is <?php echo $user->username; ?>'s Profile
</div>
Profile
<hr/>
</td>
</tr>
<tr>
<!-- Begin first column -->
<td class="leftColumn">
Load your information here. (Such as <?php echo $user->username; ?>«»)<br/>
It might be good to create a tab for each of these boxes.<br/>
Or you could run a SQL query to get each 'tab' in the user profile.
<br/>And do a <h3><?php echo $tab[AboutMe]->title; ?>. Then a foreach echo tab[key]: tab[value]
</td>
<!-- End first column -->

<!-- Begin second column -->
<td class="rightColumn">
</td>
<!-- End second column -->
[/code:1]

Here are two good links to look at SQL and Arrays:
SQL: www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php
Arrays: www.desilva.biz/arrays/multidimen.html

Post edited by: chucktrukk, at: 2006/12/01 17:34

Please Log in to join the conversation.

17 years 3 months ago #26152 by radio
Replied by radio on topic Re:Chucks Extended Profile
Okey iv started to get somewhere now, I am however still haveing a little trouble with the styleing text in the top position next to avator, I would usualy style this in the external css but i cant, can i use inline or something? I want to change the color font and size of the text, I am also have trouble posistioning the tabs in the knew right hand coloumb.

chucktrukk wrote:

radio,

You can create a profile like www.mingleville.com/xL15Ax? with something like the following:

[code:1]
<table class="xtdUserProfileWrapper">
<tr>
<td colspan="2">
Header here - Register, login links here
</td>
</tr>
<tr>
<td colspan="2">
<!-- Top row of links -->
<?php echo $userViewTabs["cb_head"]; ?>
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
Rating<br/> <em>I never figured how to get the rating to work correctly</em>
</div>
<!-- Your Avatar -->
<img src="<?php echo $avatar_img; ?>" title="Your Avatar" alt="Your Avatar" align="left" />
<?php echo $user->username; ?>
<br/>
Name: <?php echo $user->firstname; ?>
Age: <?php echo $user->age; ?>
Gender: <?php echo $user->gender; ?>
<br/>
Town/City: <?php echo $user->city; ?>
Country: <?php echo $user->country; ?>
<br/>
Links here, such as: Send a Message, Donate Points , Add to Buddy List, Add to Block List
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
This is <?php echo $user->username; ?>'s Profile
</div>
Profile
<hr/>
</td>
</tr>
<tr>
<!-- Begin first column -->
<td class="leftColumn">
Load your information here. (Such as <?php echo $user->username; ?>«»)<br/>
It might be good to create a tab for each of these boxes.<br/>
Or you could run a SQL query to get each 'tab' in the user profile.
<br/>And do a <h3><?php echo $tab[AboutMe]->title; ?>. Then a foreach echo tab[key]: tab[value]
</td>
<!-- End first column -->

<!-- Begin second column -->
<td class="rightColumn">
</td>
<!-- End second column -->
[/code:1]

Here are two good links to look at SQL and Arrays:
SQL: www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php
Arrays: www.desilva.biz/arrays/multidimen.html

Post edited by: chucktrukk, at: 2006/12/01 17:34


Post edited by: radio, at: 2006/12/04 04:09

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in to join the conversation.

17 years 3 months ago #26231 by chucktrukk
Replied by chucktrukk on topic Re:Chucks Extended Profile
radio,

You can use an external CSS for this page. The Joomla index file is loaded, so any CSS in here will be loaded.

But you can also use any inline CSS for this as well.

You dont have to use any of my code. It was just an example.

Please Log in to join the conversation.

17 years 3 months ago #26241 by radio
Replied by radio on topic Re:Chucks Extended Profile
Yeah i know i dont have to use it mate, but since i could'nt have done it myself, and it does what i want then i may as well use it, ;), There wont be any performace issues with cb and large userbase sites using your code will there?


Could you give me an example of how to style this part using inline css? I cant figure out how to style it in my template css file because they are not in any of the normal tabs or feilds:

Name: <?php echo $user->firstname; ?>
Age: <?php echo $user->age; ?>
Gender: <?php echo $user->gender; ?>
<br/>
Town/City: <?php echo $user->city; ?>
Country: <?php echo $user->country; ?>
<br/>
Links here, such as: Send a Message, Donate Points , Add to Buddy List, Add to Block List
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
This is <?php echo $user->username; ?>'s Profile
</div>

ID also like to chnage the color of the line running across the page at this part:
This is <?php echo $user->username; ?>'s Profile
</div>


Sorry for the hassle mate im almost their

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in to join the conversation.

17 years 3 months ago #26254 by chucktrukk
Replied by chucktrukk on topic Re:Chucks Extended Profile
radio wrote:

Name: <?php echo $user->firstname; ?>
Age: <?php echo $user->age; ?>
Gender: <?php echo $user->gender; ?>
<br/>
Town/City: <?php echo $user->city; ?>
Country: <?php echo $user->country; ?>
<br/>
Links here, such as: Send a Message, Donate Points , Add to Buddy List, Add to Block List
</td>
</tr>
<tr>
<td colspan="2">
<div style="float:right; width:125px;">
This is <?php echo $user->username; ?>'s Profile
</div>

ID also like to chnage the color of the line running across the page at this part:
This is <?php echo $user->username; ?>'s Profile


Radio,

If it was me, I wouldn't do inline styles. I would do the following:

If you want a consistent look for all of name, age, gender, etc. do the following:

<div class="userinfo">
<span class="title">Name: </span>
<span class="attribute"><?php echo $user->firstname; ?></span>

<br/>

<span class="title">Age: </span>
<span class="attribute"><?php echo $user->age; ?></span>

etc...
</div>


Then in your CSS create the following styles:
div.userinfo {
background: ;
padding: ;
/* etc.. */
}

div.userinfo .title {
color: ;
padding: ;
/* etc.. */
}

div.userinfo .attribute {
color: ;
padding: ;
/* etc.. */
}

That is how I would do it. Or you can use inline styles such as

<span style="color: #000; padding: 10px;">Something here</span>

But when developing for a J! site, I have found keeping everything in the template.css file makes things easier (for me). I usually use inline styles when I am working on layout, then port it to the template_css.css when I am finished.

Hope that helps. Chuck

PS - I am no CSS or PHP guru. I am light-years behind beat and the group. A resource I use daily is: www.w3schools.com/css/default.asp

Post edited by: chucktrukk, at: 2006/12/04 22:47

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.229 seconds

Facebook Twitter LinkedIn