Keyword

Trying to define spesific extra field

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
9 years 8 months ago - 9 years 8 months ago #140287 by John-Eilif Eliassen
Trying to define spesific extra field was created by John-Eilif Eliassen
Hello, im working on a site where I want to display a team. The way I have done this is by creating a K2 category, and in that category I have an extra field group associated, with only one extra field. I've created empty articles in that category with only the ID of actual team members in the extra field.

Now im trying to echo/define that extra field as $user in the templates/team/category_item.php to fetch certain info from the spesified userid such as avatar and some other fields. I dont know the "industry language" but I have tried to call the extra field and define it as $user as shown below, can anybody tell me how to define it properly? When I do as below, the page is corrupt.
<?php
// no direct access
defined('_JEXEC') or die;

// Define default image size (do not change)
K2HelperUtilities::setDefaultImage($this->item, 'itemlist', $this->params);

// JOMSOCIAL USER
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');

//get cuser and some field values
$user = $this->item->extraFields->PlayerID->value);
$avatarUrl = $user->getThumbAvatar();

$link = CRoute::_('index.php?option=com_community&view=profile&userid='.$user);
$desc = $user->getInfo('FIELD_DESC'); 

?>

In combination with:
<div class="pagePlayer">
	<div class="playerAvatar">
		<img src="<?php echo $avatarUrl;?>">
	</div>
	<div class="playerDesc">
		<?php echo $desc;?>
	</div>
</div>

I will be very happy if someone can help me with this.
Last edit: 9 years 8 months ago by John-Eilif Eliassen.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #140318 by Lefteris
Replied by Lefteris on topic Trying to define spesific extra field
Hi,

I am not sure that i got this completely but if you mean that the extra field holds the ID of a Joomla! user then you can use this code:
$player = JUser::getInstance($this->item->extraFields->PlayerID->value);

This will give you the Joomla! user, however i don't know how you can get it's profile from JomSocial. This is something you need to ask to JomSocial developers.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
9 years 8 months ago #140334 by John-Eilif Eliassen
Replied by John-Eilif Eliassen on topic Trying to define spesific extra field
Hello and thank you for your answer! Really appreciate it.

I'll try to explain a bit, to display different teams on different menu-items i have created a category in K2 called "Players", in this category I have published one article representing each player. These articles are associated with a extra-field group called "Players", in this field group there are only one extra field named "PlayerID" with the same alias. In this field, each player has their own userid and now I need to define that in the category_item.php header so that I am able to integrate JomSocial-fields in those K2 articles.

I know I've done this before once, maybe 4 years ago. But sadly I cant recall what I did in the header to make this possible. Now my page errors out in the "players" category whenever I add something in addition to
$playerID = JUser::getInstance($this->item->extraFields->PlayerID->value);

For instance, when I call for the avatarUrl the site errors out. I think I'm on to something now, so I'll work a bit more on it and leave an update here afterwards. I just have to play around a bit :)

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago - 9 years 7 months ago #140336 by alexandria
Replied by alexandria on topic Trying to define spesific extra field
Hello,
there is some links on the web about jomsocial
www.reviewsforjoomla.com/forum/index.php?topic=21544.0
Last edit: 9 years 7 months ago by alexandria.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum