ysva's CB Custom Profile's [Tips and Tricks]

17 years 5 months ago #25941 by chucktrukk
Replied by chucktrukk on topic Re:ysva's CB Custom Profile's [Tips and Tricks]
radio,

This is my UserProfile code (it's not updated for 1.2):

function userProfile
[code:1]
global $database, $_REQUEST, $ueConfig, $my;
if (isset($_REQUEST)) {
if (!allowAccess( $ueConfig,'RECURSE', userGID($my->id))) {
echo _UE_NOT_AUTHORIZED;
return;
}
} else {
if ($uid==0) {
echo _UE_REGISTERFORPROFILE;
return;
}
}
$users=array();
if (setUserDBrequest($uid)) {
$users = $database->loadObjectList();
}
if (count($users)==0) {
echo _UE_NOSUCHPROFILE;
return;
}

$user = $users[0];

HTML_comprofiler::«»xtdUserProfile( $user, $option, $submitvalue, $my);
[/code:1]

Then I added a new function to comprofiler.html.php (underneath userProfile)
[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>\n";
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>\n";
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>\n";

if($my->id!=$user->id) {
recordViewHit($my->id,$user->id,getenv('REMOTE_ADDR'));
}
$_PLUGINS->trigger( 'onAfterUserProfileDisplay', array($user,true));
}
}
[/code:1]

Then I created a folder called components/com_comprofiler/xtd_views/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);

?>

<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>
[/code:1]

What this does is allow you to modify xtdUserProfile to look however you want more easily (at least for me).

There may be some errors in there.

Chuck

Of course I make no warranties, etc al.

Please Log in to join the conversation.

17 years 5 months ago #25953 by radio
Thanks but im not sure how to actually go about using this code, I dont know php at all and bearly know html and css, could you explain in a bit more detail what each part does and how to use it?

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

Please Log in to join the conversation.

17 years 5 months ago #25954 by radio
okey iv added the code to my test server files,its knocked my current layout all outta whack, I can see from vewing the source html that there is alot of changes, is it just a case of using the css to make the profile look how i want with all the knew classes ect? or is there more to it ? Like i said you'l need to explain how i use this modification and will it let me build a profile page with two columbs similar to this: www.mingleville.com/xL15Ax?


cheers mate

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

Please Log in to join the conversation.

17 years 5 months ago #25992 by chucktrukk
Replied by chucktrukk on topic Re:ysva's CB Custom Profile's [Tips and Tricks]
radio,

I dont want to hijack ysva's thread. So I moved the topic here: www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,29/id,25991/

Please Log in to join the conversation.

17 years 5 months ago #26054 by ysva
chucktrukk wrote:

radio,

I dont want to hijack ysva's thread. So I moved the topic here: www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,29/id,25991/


I don't mind any hijack at all, we're all working on the goal which we share:

open up CB customizability.:side:

Please Log in to join the conversation.

17 years 4 months ago #26897 by pointri
Here's a quick trick to dynamically change the name of a profile tab, depending on a particular field.

In this example, _UE_SVC_TAB is a constant defined in a plugin of your choosing in the Plugin Manager.

In the plugin's language file, throw in this function.

[code:1]function _nameTab(&$group) {
if ($group == "foos"«») {
DEFINE('_UE_SVC_TAB','Foo Club');
} else {
DEFINE('_UE_SVC_TAB','Bar Club');
}
}[/code:1]

In most plugins, there's a subroutine that calls for a language file. After the lines which include the language file, call the _nameTab function. Here's how it looks in a plugin I'm working on.

[code:1]function _getLanguageFile($user->cb_group) {
global $mosConfig_absolute_path, $mosConfig_lang;
if (file_exists($mosConfig_absolute_path."/components/com_comprofiler/plugin/user/plug_servicestab/language/".$mosConfig_lang.".php"«») ) {
include_once($mosConfig_absolute_path."/components/com_comprofiler/plugin/user/plug_servicestab/language/".$mosConfig_lang.".php"«»);
} else {
include_once($mosConfig_absolute_path."/components/com_comprofiler/plugin/user/plug_servicestab/language/english.php"«»);
}
_nameTab($user->cb_group);
return true;
}[/code:1]

Where $user is the array that holds user information in a plugin, and $user->cb_group is a member of the array that corresponds to a CB custom field: in this case, cb_group.

You can extend this to the Nth degree when customizing profile tabs based on the value of CB fields while keeping your language files intact and independent of the main flow of the plugin.

Joomlapolitan zealot and a somewhat stealthy, rather passive CB3PD developer.
www.constructionlounge.com Construction Lounge: Online resource and networking portal for the construction and remodeling industries.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.327 seconds

Facebook Twitter LinkedIn