COMMUNITY FORUM
How to: SIG Pro gallery in Tag view
- Rui Braz
-
Topic Author
- Offline
- New Member
I want my K2 tag views to be similar to the category view, so I'm trying to get SIG Pro galleries to show in tag views, with no luck.
Is this possible? Does anyone know how to do it?
All help is appreciated. Thank you in advance!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
<div class="catItemIntroText tagItemIntroText">
<?php echo $item->introtext; ?>
</div>
and replace it with:
<div class="catItemIntroText tagItemIntroText">
<?php
$introtext = JHtml::_('content.prepare', $item->introtext);
echo $introtext;
?>
</div>
in order to locate and override the file please read this post:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
Thanks for your help.
I replaced the block of code you mentioned, but no SIG gallery is shown.
I tried both with a template override and directly changing the tag.php in the K2 component folder.
Am I missing something?
Since SIG is a plugin, could it be something with the order of the plugins?
Also: tag.php is missing the following line that is present, p.e., in category_item.php:
<!-- K2 Plugins: K2BeforeDisplay -->
<?php echo $this->item->event->K2BeforeDisplay; ?>
I tried adding this to tag.php, with no results.
For reference: I'm using J3.4.1 and K2 v2.6.9 with T3 Framework. Aside a few customizations in CSS, K2 is as close to stock as possible.
Thank you.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
The plugin order will not affect this, you need to do it manually.
I will have to get back to you with another snippet.
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
I'll be anxiously waiting!
Best regards!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
I've read the post you directed me to, and I tried using the code provided there, but it is not clear from the post where to insert the code or event if it worked. I tried pasting the code inside the foreach, above it, below it... you name it. I even tried playing with the code a bit, but I know nothing about PHP (mental note: take a crash course on PHP...).
So, sorry to bother you, but here I am asking your help once more.
My actual tag.php reads like this now:
<?php
/**
* @version 2.6.x
* @package K2
* @author JoomlaWorks https://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<!-- Start K2 Tag Layout -->
<div id="k2Container" class="tagView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
<?php if($this->params->get('show_page_title')): ?>
<!-- Page title -->
<div class="componentheading<?php echo $this->params->get('pageclass_sfx')?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>
<?php if($this->params->get('tagFeedIcon',1)): ?>
<!-- RSS feed icon -->
<div class="k2FeedIcon">
<a href="<?php echo $this->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?>">
<span><?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?></span>
</a>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if(count($this->items)): ?>
<div class="tagItemList">
<?php foreach($this->items as $item):
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('K2AfterDisplayContent', array(&$item, &$params, $limitstart));
$this->event->K2AfterDisplayContent = trim(implode("\n", $results));
?>
<!-- Start K2 Item Layout -->
<div class="tagItemView">
<div class="tagItemHeader">
<?php if($item->params->get('tagItemDateCreated',1)): ?>
<!-- Date created -->
<span class="tagItemDateCreated">
<?php echo JHTML::_('date', $item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<?php endif; ?>
<?php if($item->params->get('tagItemTitle',1)): ?>
<!-- Item title -->
<h2 class="tagItemTitle">
<?php if ($item->params->get('tagItemTitleLinked',1)): ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else: ?>
<?php echo $item->title; ?>
<?php endif; ?>
</h2>
<?php endif; ?>
</div>
<div class="tagItemBody">
<?php if($item->params->get('tagItemImage',1) && !empty($item->imageGeneric)): ?>
<!-- Item Image -->
<div class="tagItemImageBlock">
<span class="tagItemImage">
<a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $item->params->get('itemImageGeneric'); ?>px; height:auto;" />
</a>
</span>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemIntroText',1)): ?>
<!-- Item introtext -->
<!--
<div class="tagItemIntroText">
<?php echo $item->introtext; ?>
</div>
-->
<div class="catItemIntroText tagItemIntroText">
<?php
$introtext = JHtml::_('content.prepare', $item->introtext);
echo $introtext;
?>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<div class="clr"></div>
<?php if($item->params->get('tagItemExtraFields',0) && count($item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="tagItemExtraFields">
<h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4>
<ul>
<?php foreach ($item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="tagItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="tagItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="tagItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemCategory')): ?>
<!-- Item category name -->
<div class="tagItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<a href="<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
</div>
<?php endif; ?>
<?php if ($item->params->get('tagItemReadMore')): ?>
<!-- Item "read more..." link -->
<div class="tagItemReadMore">
<a class="k2ReadMore" href="<?php echo $item->link; ?>">
<?php echo JText::_('K2_READ_MORE'); ?>
</a>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<!-- End K2 Item Layout -->
<?php endforeach; ?>
</div>
<!-- Pagination -->
<?php if($this->pagination->getPagesLinks()): ?>
<div class="k2Pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
<?php echo $this->pagination->getPagesCounter(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- End K2 Tag Layout -->
Any ideas?
Thank you for your patience.
Best regards.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Then replace the K2AfterDisplayContent hook with onPrepareContent (my bad)
eg:
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$dispatcher->trigger('onContentPrepare', array(&$item, &$params, $limitstart));
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
All I get is an almost bank page: just the page title and rss link with no styling.
I tried putting the code on the top, just below "defined('_JEXEC') or die;" and also inside the "<?php foreach($this->items as $item):" declaration around line 44. Aldo tried both introtext pieces of code. Same results.
I must be missing something...
Best regards.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Enable error reporting and set it to development from your site's global configuration to see the actual issue.
Please Log in or Create an account to join the conversation.
- Ronny Van Der Borght
-
- Offline
- Senior Member
This is the code from tag.php:
<?php if(count($this->items)): ?>
<?php foreach($this->items as $item): ?>
<?php $dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('K2AfterDisplayContent', array(&$item, &$params, &$limitstart));
$this->event->K2AfterDisplayContent = trim(implode("\n", $results)); ?>
<?php echo $item->introtext; ?>
<?php echo $item->gallery; ?>
<?php endforeach; ?>
<?php endif; ?>
Can you spot the error ?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
After a ton of copy&pasting, a ton of trials&erros, I managed to get a working tag.php!
I'm posting it to help others with the same issue:
<?php
/**
* @version 2.6.x
* @package K2
* @author JoomlaWorks https://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<!-- Start K2 Tag Layout -->
<div id="k2Container" class="tagView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
<?php if($this->params->get('show_page_title')): ?>
<!-- Page title -->
<div class="componentheading<?php echo $this->params->get('pageclass_sfx')?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>
<?php if($this->params->get('tagFeedIcon',1)): ?>
<!-- RSS feed icon -->
<div class="k2FeedIcon">
<a href="<?php echo $this->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?>">
<span><?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?></span>
</a>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if(count($this->items)): ?>
<?php echo $item->introtext; ?>
<?php
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$params = JComponentHelper::getParams('com_k2');
?>
<div class="tagItemList">
<?php foreach($this->items as $item): ?>
<?php if ($item->gallery)
{
if (JString::strpos($item->gallery, 'flickr.com') === false)
{
$item->gallery = "{gallery}{$item->id}{/gallery}";
}
$params->set('galleries_rootfolder', 'media/k2/galleries');
$item->text = $item->gallery;
$dispatcher->trigger('onContentPrepare', array(
'com_k2.itemlist',
&$item,
&$params,
$limitstart
));
$item->gallery = $item->text;
} ?>
<?php echo $item->gallery; ?>
<?php if ($item->video)
{
$item->gallery = "{youtube}{$item->id}{/youtube}";
$item->text = $item->video;
$dispatcher->trigger('onContentPrepare', array(
'com_k2.itemlist',
&$item,
&$params,
$limitstart
));
$item->video = $item->text;
} ?>
<?php echo $item->video; ?>
<!-- Start K2 Item Layout -->
<div class="tagItemView">
<div class="tagItemHeader">
<?php if($item->params->get('tagItemDateCreated',1)): ?>
<!-- Date created -->
<span class="tagItemDateCreated">
<?php echo JHTML::_('date', $item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<?php endif; ?>
<?php if($item->params->get('tagItemTitle',1)): ?>
<!-- Item title -->
<h2 class="tagItemTitle">
<?php if ($item->params->get('tagItemTitleLinked',1)): ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else: ?>
<?php echo $item->title; ?>
<?php endif; ?>
</h2>
<?php endif; ?>
</div>
<div class="tagItemBody">
<?php if($item->params->get('tagItemImage',1) && !empty($item->imageGeneric)): ?>
<!-- Item Image -->
<div class="tagItemImageBlock">
<span class="tagItemImage">
<a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $item->params->get('itemImageGeneric'); ?>px; height:auto;" />
</a>
</span>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemIntroText',1)): ?>
<!-- Item introtext -->
<div class="tagItemIntroText">
<?php echo $item->introtext; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<div class="clr"></div>
<?php if($item->params->get('tagItemExtraFields',0) && count($item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="tagItemExtraFields">
<h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4>
<ul>
<?php foreach ($item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="tagItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="tagItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="tagItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemCategory')): ?>
<!-- Item category name -->
<div class="tagItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<a href="<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
</div>
<?php endif; ?>
<?php if ($item->params->get('tagItemReadMore')): ?>
<!-- Item "read more..." link -->
<div class="tagItemReadMore">
<a class="k2ReadMore" href="<?php echo $item->link; ?>">
<?php echo JText::_('K2_READ_MORE'); ?>
</a>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<!-- End K2 Item Layout -->
<?php endforeach; ?>
</div>
<!-- Pagination -->
<?php if($this->pagination->getPagesLinks()): ?>
<div class="k2Pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
<?php echo $this->pagination->getPagesCounter(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- End K2 Tag Layout -->
Thank you Krikor (and Ronny in the other thread you point me to)! I wouldn't have done it without you!
Please Log in or Create an account to join the conversation.
- Rui Braz
-
Topic Author
- Offline
- New Member
Small correction to the tag.php posted earlier:
<?php
/**
* @version 2.6.x
* @package K2
* @author JoomlaWorks https://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<!-- Start K2 Tag Layout -->
<div id="k2Container" class="tagView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">
<?php if($this->params->get('show_page_title')): ?>
<!-- Page title -->
<div class="componentheading<?php echo $this->params->get('pageclass_sfx')?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>
<?php if($this->params->get('tagFeedIcon',1)): ?>
<!-- RSS feed icon -->
<div class="k2FeedIcon">
<a href="<?php echo $this->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?>">
<span><?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?></span>
</a>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if(count($this->items)): ?>
<?php echo $item->introtext; ?>
<?php
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$params = JComponentHelper::getParams('com_k2');
?>
<div class="tagItemList">
<?php foreach($this->items as $item): ?>
<?php if ($item->gallery)
{
if (JString::strpos($item->gallery, 'flickr.com') === false)
{
$item->gallery = "{gallery}{$item->id}{/gallery}";
}
$params->set('galleries_rootfolder', 'media/k2/galleries');
$item->text = $item->gallery;
$dispatcher->trigger('onContentPrepare', array(
'com_k2.itemlist',
&$item,
&$params,
$limitstart
));
$item->gallery = $item->text;
} ?>
<?php if ($item->video)
{
$item->gallery = "{youtube}{$item->id}{/youtube}";
$item->text = $item->video;
$dispatcher->trigger('onContentPrepare', array(
'com_k2.itemlist',
&$item,
&$params,
$limitstart
));
$item->video = $item->text;
} ?>
<!-- Start K2 Item Layout -->
<div class="tagItemView">
<div class="tagItemHeader">
<?php if($item->params->get('tagItemDateCreated',1)): ?>
<!-- Date created -->
<span class="tagItemDateCreated">
<?php echo JHTML::_('date', $item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<?php endif; ?>
<?php if($item->params->get('tagItemTitle',1)): ?>
<!-- Item title -->
<h2 class="tagItemTitle">
<?php if ($item->params->get('tagItemTitleLinked',1)): ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else: ?>
<?php echo $item->title; ?>
<?php endif; ?>
</h2>
<?php endif; ?>
</div>
<div class="tagItemBody">
<?php if($item->params->get('tagItemImage',1) && !empty($item->imageGeneric)): ?>
<!-- Item Image -->
<div class="tagItemImageBlock">
<span class="tagItemImage">
<a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $item->params->get('itemImageGeneric'); ?>px; height:auto;" />
</a>
</span>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemIntroText',1)): ?>
<!-- Item introtext -->
<div class="tagItemIntroText">
<?php echo $item->introtext; ?>
<?php echo $item->gallery; ?>
<?php echo $item->video; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<div class="clr"></div>
<?php if($item->params->get('tagItemExtraFields',0) && count($item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="tagItemExtraFields">
<h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4>
<ul>
<?php foreach ($item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="tagItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="tagItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="tagItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemCategory')): ?>
<!-- Item category name -->
<div class="tagItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<a href="<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
</div>
<?php endif; ?>
<?php if ($item->params->get('tagItemReadMore')): ?>
<!-- Item "read more..." link -->
<div class="tagItemReadMore">
<a class="k2ReadMore" href="<?php echo $item->link; ?>">
<?php echo JText::_('K2_READ_MORE'); ?>
</a>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<!-- End K2 Item Layout -->
<?php endforeach; ?>
</div>
<!-- Pagination -->
<?php if($this->pagination->getPagesLinks()): ?>
<div class="k2Pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
<?php echo $this->pagination->getPagesCounter(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- End K2 Tag Layout -->
Please Log in or Create an account to join the conversation.