Quote

We're also available for Custom Joomla Development

Hire us now

Mini K2 customization

I tried to add specific "K2 extra filed" to Mini K2 as explained in this tutorial:
http://getk2.org/documentation/tips-a-tricks/item/221-custom-admin-templates-and-calling-specific-extra-field-data

For some reason it doesn`t work. Is where some solution to display specific extra field in Mini K2 module (Simple template)?

Thank you in advance,
Gideon
       
  • Replied by erwinschro on Monday, December 03 2012, 04:58 PM · Hide· #1
    Hello

    I believe you have standart K2 content module in place (mod_k2_content). If you take a closer look at it's mod_k2_content/tmpl/default.php, you will see this extrafields part below where you can paste it on .mod_minik2/tmpl/simple/default.php

    <?php if($params->get('itemExtraFields') && count($item->extra_fields)): ?>
          <div class="moduleItemExtraFields">
    	      <b><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></b>
    	      <ul>
    	        <?php foreach ($item->extra_fields as $extraField): ?>
    					<?php if($extraField->value): ?>
    					<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
    						<span class="moduleItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
    						<span class="moduleItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
    						<div class="clr"></div>
    					</li>
    					<?php endif; ?>
    	        <?php endforeach; ?>
    	      </ul>
          </div>
    <?php endif; ?>


    Have a try...
  •  
  • Replied by atanetfq on Monday, December 03 2012, 05:05 PM · Hide· #2
    It doesnt help... I tried it before posting here. And I need to display specific extra field, not all of them
  •  
  • Replied by erwinschro on Monday, December 03 2012, 05:22 PM · Hide· #3
    I didn't read well before that you need only a specific extrafield.
    For that then you need to count which one from those extrafields you've created in order. For example if it's an extrafield n-th then you should call it with

    <?php
    echo $item->extra_fields[n-1]->value;
    ?>
  •  
  • Replied by atanetfq on Monday, December 03 2012, 06:49 PM · Hide· #4
    You mean, if I want to display extra field that has ID=1, so I should use this code ( n-1 = 1-1 = 0) :
    <?php
    echo $item->extra_fields[0]->value;
    ?>


    Thank you in advance
  •  
  • Replied by memofree on Thursday, January 10 2013, 02:47 AM · Hide· #5
    my extrafields group name "book"

    extrafield id 1 name "pages"
    extrafield id 2 name "cover"

    how i show in mini k2
  •  
  • Replied by erwinschro on Thursday, January 10 2013, 05:09 AM · Hide· #6
    Hi Memofree

    Have you try to follow the steps above? where you could add this line

    <?php echo $item->extra_fields[0]->value; ?>


    on any minik2 layout file you choose i.e /modules/mod_minik2/tmpl/simple/default.php

    And for your specific case - extrafield with id 1 and 2 - the code could look like,

    <?php echo $item->extra_fields[0]->value; ?>
    <?php echo $item->extra_fields[1]->value; ?>
    
  •  
  •  
    Replied by mrwebmanager on Saturday, September 10 2016, 01:59 PM · Hide· #7
    hi all

    i use this code to show specific extra fields with id 1 to simple template of mini k2 but its not appear in front end, can anybody help?

    <?php
    /**
     * @version		$Id: default.php 565 2010-09-23 11:48:48Z joomlaworks $
     * @package		K2
     * @author		JoomlaWorks http://www.joomlaworks.gr
     * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
     * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
     */
    
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    ?>
    <div class="minik2" id="minik2<?php echo $modid; ?>">
    
    <?php 
    $numofitems = count($items);
    if($numofitems): 
    		
    	foreach ($items as $key=>$item):	
    	
    	?>
              
    		<div class="k2item block">
    			<?php if ($item->image) { ?>
    			<div class="thumbs-wrapper">
    <?php if($params->get('itemCategory')): ?>
    			<div style="position:relative; z-index:110;"><span class="itemCategory"></div>
    				<p style="position:relative; z-index:110;color: #fff;text-align: center;font-size: 14px;" class="moduleItemCategory <?php echo $item->categoryalias; ?>"><?php echo $item->categoryname; ?></p>
    			</span>
    			<?php endif; ?>
    				<div class="thumbs">
    					<a href="/<?php echo $item->link; ?>">
    					<img src="/<?php echo $item->image; ?>" alt="<?php echo $item->title; ?>" class="box-img" />
    					</a>
                                                 <div class="year-div" style="position: absolute;background: #fb0b0b;padding: 10px;transform: rotate(45deg);top: 22px;right: -26px;width: 65px;height: 13px;">
      <p class="year-no" style="color: #fff;font-size: 13px;position: relative;top: 1px;right: 12px;"><?php echo $item->extra_fields[0]->value; ?></p> </div>
    				</div>
    			</div>
    			<?php } ?>
    			                          
    			<h2 class="title"><a style="font-size: 12px;font-family: arial;" dir="ltr" href="/<?php echo $item->link; ?>"><?php echo $item->title; ?></a></h2>
    			
    			<?php if($params->get('itemDateCreated')): ?>
    			<!-- Date created -->
    			<span class="itemDateCreated">
    				<?php echo JHTML::_('date', $item->created , JText::_('DATE_FORMAT_LC3')); ?>
    			</span>
    			<?php endif; ?>
    			
    			
                
    			<?php if($params->get('itemHits')) { ?>
    			<span class="itemDateCreated">
    				<?php echo $item->hits; ?> <?php echo JText::_('hits'); ?>
                </span>
    			<?php } ?>
    			
    				
    			<?php if($params->get('itemIntroText')): ?>
    				<div>
    					<p class="minik2-simple-intro">
    						<?php echo $item->introtext; ?>
    					</p>
    				</div>
    			<?php endif; ?>
    		
                <!-- Item Rating -->
    				<?php if($params->get('itemVotesNumber') || $params->get('itemVotesNumber') ) { ?>
    				<div class="minik2-simple-rating">
    					<?php echo $item->voteVal; ?>
    					&nbsp;from&nbsp;<?php echo ($item->numOfVotes==0)? '0': $item->numOfVotes; ?> <?php echo JText::_('votes'); ?>
    					
    					
    				</div>            
    				<?php } ?>
                    
    		</div>
    	<?php 
    	
    	endforeach; 
    	?>
    	<div class="clr"></div>
    <?php endif; ?>
    </div>
    
    <!-- MiniK2 Joomla 1.7 module - Another Quality Freebie from TemplatePlazza.com -->
Your Response
Please login first in order for you to submit comments