Hello,
We would like to add the gkAvatar for the authors in a custom categories listing template display.
Please see the picture in attachment for a more detailed explanation.
Regards.
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left;" />
<div class="itemBlock">
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
<div class="itemImageBlock"> <a class="itemImage" href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
<?php if($this->item->category->id == '28')?>
teitbite wrote:Hi
Great to hear that, but I'm afraid I do not understand how You did this I mean how You have separated this to a one category only. Have You created a new k2 template and attached to this one categoru only in k2 category settings or used a condition in default layout like:
- Code: Select all
<?php if($this->item->category->id == '28')?>
just an example for anyone who may be looking for a similar solution.
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />
li.itemAuthor { display: none; }
<div id="k2Container" class="itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
<div id="k2Container" class="suivi itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
.suivi li.itemAuthor { display: none; }
Check if K2 item has picture
show K2 picture
Else
Show K2 Avatar
<?php if(empty($this->item->image): ?>
<?php $this->item->image = $this->item->author->avatar; ?>
<?php endif; ?>
<a href="<?php echo $this->item->link; ?>"> </a>
<a href="<?php echo $this->item->link; ?>"> </a>
?>
<article class="itemView group<?php echo ucfirst($this->item->itemGroup); ?><?php echo ($this->item->featured) ? ' itemIsFeatured' : ''; ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?><?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): echo ' has-image'; endif; ?>"> <?php echo $this->item->event->BeforeDisplay; ?> <?php echo $this->item->event->K2BeforeDisplay; ?>
<div class="itemBlock">
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
<div class="itemImageBlock"> <a class="itemImage" href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
</a> </div>
<?php endif; ?>
/<br />
<b>Notice</b>: Undefined property: stdClass::$author in <b>/home2/guitar88/public_html/_mig2/templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>/home2/guitar88/public_html/_mig2/templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php</b> on line <b>17</b><br />
quebecguitare wrote:Entire category with the template Suivi_K2 have their images replaced with the K2 avatar, even though there is images in the first place.
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left;" />
You need to change template's override for this file which is in templates/gk_john_s/html/com_k2/templates/default/category_item.php
<?php if(empty($this->item->image)): ?>
<?php $this->item->image = $this->item->author->avatar; ?>
<?php endif; ?>
<div id="k2Container" class="suivi_k2 itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
<a href="<?php echo $this->item->link; ?>"> </a>
<?php if(empty($this->item->image): ?>
<?php $this->item->image = $this->item->author->avatar; ?>
<?php endif; ?>