0

I'm new with PHP and I'm developing a website with joomla 3. I have a module which is k2 users where I show all k2 users, well, I want to add to this module some fields from the User Extended Fields Plugin and I don't know how to do it. What I have tried it's this:

<?php


// no direct access
defined('_JEXEC') or die;
$params = K2HelperUtilities::getParams('com_k2');
$limitstart = JRequest::getInt('limitstart');
?>

<div id="k2ModuleBox<?php echo $module->id; ?>" class="k2UsersBlock<?php    if($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); ?>">
   <table id="tUsuarios">
   <thead>
   <tr>
       <th>Avatar</th>
       <th>Nombre</th>
       <th>Descripción</th>
       <th>Correo</th>
   </tr>
 </thead>
 <tbody>
        <?php foreach($users as $key=>$user): 

        $dispatcher = JDispatcher::getInstance();
                        JPluginHelper::importPlugin('k2');
                        $results = $dispatcher->trigger('onK2UserDisplay', array(&$user->profile, &$params, $limitstart));
                echo $user->youtube;
    ?>
    <tr class="<?php echo ($key%2) ? "odd" : "even"; if(count($users)==$key+1) echo ' lastItem'; ?>">
      <td>  
        <?php if($userAvatar && !empty($user->avatar)): ?>
        <a class="k2Avatar ubUserAvatar" rel="author" href="<?php echo $user->link; ?>" title="<?php echo K2HelperUtilities::cleanHtml($user->name); ?>">
            <img src="<?php echo $user->avatar; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($user->name); ?>" style="width:<?php echo $avatarWidth; ?>px;height:auto;" />
        </a>
        <?php endif; ?>
      </td>
      <td>  
        <?php if($userName): ?>
        <a class="ubUserName" rel="author" href="<?php echo $user->link; ?>" title="<?php echo K2HelperUtilities::cleanHtml($user->name); ?>">
            <?php echo $user->name; ?>
        </a>
        <?php endif; ?>
     </td>
     <td>   
        <?php if($userDescription && $user->description): ?>
        <div class="ubUserDescription">
            <?php if($userDescriptionWordLimit): ?>
            <?php echo K2HelperUtilities::wordLimit($user->description, $userDescriptionWordLimit) ?>
            <?php else: ?>
            <?php echo $user->description; ?>
            <?php endif; ?>
        </div>

        <?php endif; ?>
     </td>
     <td>
        <?php if($userFeed || ($userURL && $user->url) || $userEmail): ?>
        <div class="ubUserAdditionalInfo">

            <?php if($userFeed): ?>
            <!-- RSS feed icon -->
            <a class="ubUserFeedIcon" href="<?php echo $user->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_USERS_RSS_FEED'); ?>">
                <span><?php echo JText::_('K2_SUBSCRIBE_TO_THIS_USERS_RSS_FEED'); ?></span>
            </a>
            <?php endif; ?>

            <?php if($userURL && $user->url): ?>
            <a class="ubUserURL" rel="me" href="<?php echo $user->url; ?>" title="<?php echo JText::_('K2_WEBSITE'); ?>" target="_blank">
                <span><?php echo JText::_('K2_WEBSITE'); ?></span>
            </a>
            <?php endif; ?>

            <?php if($userEmail): ?>
            <span class="ubUserEmail" title="<?php echo JText::_('K2_EMAIL'); ?>">
                <?php echo JHTML::_('Email.cloak', $user->email); ?>
            </span>
            <?php endif; ?>
        </div>
        <?php endif; ?>
      </td>
      <td>  
        <?php if($userItemCount && count($user->items)): ?>
        <h3><?php echo JText::_('K2_RECENT_ITEMS'); ?></h3>
        <ul class="ubUserItems">
            <?php foreach ($user->items as $item): ?>
            <li>
                <a href="<?php echo $item->link; ?>" title="<?php echo K2HelperUtilities::cleanHtml($item->title); ?>">
                    <?php echo $item->title; ?>
                </a>
            </li>
            <?php endforeach; ?>
        </ul>
        <?php endif; ?>
      </td> 
        <div class="clr"></div>
    </li>
    </tr>
    <?php endforeach; ?>
</tbody>    
</table>

How can I do it?, Thanks a lot in advance.

  • First thing is first, do not edit the core module. Create a Template Override for it – Lodder Jan 24 '15 at 15:17
  • Ok, and after that? – zoit Jan 24 '15 at 15:21
  • I've not used this before, but have a look at the first reply here; joomlaworks.net/forum/… – Lodder Jan 24 '15 at 15:29
  • It would be the same with User Extended Fields? – zoit Jan 24 '15 at 15:45
  • 1
    The generic answer is to find a view that shows the info you want and then use the copy paste method of programming. You need to be able to read the code so you can recognize the correct part and possible dependencies, usually the parts that actually fetch the data, but usually template overrides are much easier to make than I assumed before actually trying. But I don't have experience with K2 either... – Ville Niemi Jan 24 '15 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.