- Posts: 258
- Thank you received: 24
Kunena 7.0.4 Released
The Kunena team has announce the arrival of Kunena 7.0.4 [K 7.0.4] in stable which is now available for download as a native Joomla extension for J! 5.4.x/6.0.x. This version addresses most of the issues that were discovered in K 6.2 / K 6.3 / K 6.4 and issues discovered during the last development stages of K 7.0
Solved How to add custom fields to User statistics ?
14 years 3 months ago #115714
by Baze
Replied by Baze on topic Re: How to add custom fields to User statistics ?
Ok i did it myself 
in order to show the custom fields from jomsocial in the user profiles in kunena (under the avatar), you need to open profile.vertical.php from your kunena template (it's in components/com_kunena/template/default/view/profile.vertical.php). Oh and if you are using horizontal profiles open profile.horizontal.php
At the end of the file add this:
that's it, now you can use your jomsocial custom fields in the forum
in order to show the custom fields from jomsocial in the user profiles in kunena (under the avatar), you need to open profile.vertical.php from your kunena template (it's in components/com_kunena/template/default/view/profile.vertical.php). Oh and if you are using horizontal profiles open profile.horizontal.php
At the end of the file add this:
Code:
<?php
$authorid = $this->profile->userid;
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
$user =& CFactory::getUser($authorid);
//put all your custom field code here, you can put as much as you want. In backend open components->jomsocial->custom profiles, to see your field codes and replace them in this code (replace cb_gender,cb_city..with your codes)
$data = $user->getInfo('cb_birthday');
$data1 = $user->getInfo('cb_gender');
$data2 = $user->getInfo('cb_city');
$data3 = $user->getInfo('cb_motor');
$data4 = $user->getInfo('cb_club');
//and here we print the data, you should manually change the labels (birthday, gender..) to whatever suits you
echo '<p>Birthday: '.$data.'</p>';
echo '<p>Gender: '.$data1.'</p>';
echo '<p>City: '.$data2.'</p>';
echo '<p>Motorcycle: '.$data3.'</p>';
echo '<p>Club: '.$data4.'</p>';
?>
that's it, now you can use your jomsocial custom fields in the forum
Please Log in or Create an account to join the conversation.
13 years 9 months ago - 13 years 9 months ago #128580
by Baze
Replied by Baze on topic Re: How to add custom fields to User statistics ?
Anyone has idea how can i check whether the fields have some data so that i don't show empty labels? For example the label City shows on the profile even thou the user hasn't put any data in Jomsocial for that field so it doesn't looks good.
p.s. for 2.0 and the Blue Eagle template the location of the file is in /components/com_kunena/template/blue_eagle/html/topic, and the file is default_profile_vertical.php
p.s. for 2.0 and the Blue Eagle template the location of the file is in /components/com_kunena/template/blue_eagle/html/topic, and the file is default_profile_vertical.php
Last edit: 13 years 9 months ago by Baze.
Please Log in or Create an account to join the conversation.
13 years 9 months ago #128761
by Matias
Replied by Matias on topic Re: How to add custom fields to User statistics ?
!empty($foo) ?
Please Log in or Create an account to join the conversation.
13 years 9 months ago - 13 years 9 months ago #128964
by Baze
Replied by Baze on topic Re: How to add custom fields to User statistics ?
I'd appreciate if there is some programmer who can spare me from learning php
the thing is that i'm not a developer, i managed to sort out the previous code because i can figure out the way it's working from other examples but i have no idea how to use !empty($foo) 
i'd google a bit, if i find a solution meanwhile i'll post it.
i'd google a bit, if i find a solution meanwhile i'll post it.
Last edit: 13 years 9 months ago by Baze.
Please Log in or Create an account to join the conversation.
13 years 4 months ago - 13 years 4 months ago #138592
by Baze
Replied by Baze on topic Re: How to add custom fields to User statistics ?
ok, i did it, now the code checks if the fields are empty and it shows them
/components/com_kunena/template/blue_eagle/html/topic/default_profile_vertical.php (or your templates name if you have override for default_profile_vertical.php
at the bottom add this:
/components/com_kunena/template/blue_eagle/html/topic/default_profile_vertical.php (or your templates name if you have override for default_profile_vertical.php
at the bottom add this:
Code:
<?php
$authorid = $this->profile->userid;
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
$user =& CFactory::getUser($authorid);
//put all your custom field code here, you can put as much as you want. In backend open components->jomsocial->custom profiles, to see your field codes and replace them in this code (replace cb_gender,cb_city..with your codes)
$data1 = $user->getInfo('cb_gender');
$data2 = $user->getInfo('cb_city');
$data3 = $user->getInfo('cb_motor');
$data4 = $user->getInfo('cb_club');
//and here we print the data, you should manually change the labels (birthday, gender..) to whatever suits you
if ($data1== '') {}
else {echo '<li>Gender: '.$data1.'</li>';}
if ($data2== '') {}
else {echo '<li>City: '.$data2.'</li>';}
if ($data3== '') {}
else {echo '<li>Motorcycle: '.$data3.'</li>';}
if ($data4== '') {}
else {echo '<li>Club: '.$data4.'</li>';}
?>
Last edit: 13 years 4 months ago by Baze.
The following user(s) said Thank You: flagking
Please Log in or Create an account to join the conversation.
Time to create page: 0.239 seconds