Keyword

[SOLVED] Plugins in generic.php

  • Mihail Semerdzhiev
  • Mihail Semerdzhiev's Avatar Topic Author
  • Offline
  • New Member
More
14 years 2 months ago #86629 by Mihail Semerdzhiev
[SOLVED] Plugins in generic.php was created by Mihail Semerdzhiev
Hi,how to load plugins in generic.php (tag listing view). I get the code for loading plugins from item.php:<!-- K2 Plugins: K2AfterDisplayTitle -->  <?php echo $this->item->event->K2AfterDisplayTitle; ?>  <!-- Plugins: AfterDisplayTitle -->  <?php echo $this->item->event->AfterDisplayTitle; ?>but still i can't get the plugins in tag listings :(Can anyone help?

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

More
14 years 2 months ago #86630 by Jiliko.net
Replied by Jiliko.net on topic Plugins in generic.php
Hi Mihail,

You have to add Joomla! plugin code you can find in 'components/com_k2/models/item.php' in the prepareItem() function.

You have to declare the Joomla! dispatcher :

$dispatcher = &JDispatcher::getInstance();

import Joomla content plugins :

JPluginHelper::importPlugin ('content');

import K2 plugins :

JPluginHelper::importPlugin ( 'k2' );

trigger content events :

lines 283-298

and K2 events :

lines 347-364

Olivier

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

  • Mihail Semerdzhiev
  • Mihail Semerdzhiev's Avatar Topic Author
  • Offline
  • New Member
More
14 years 2 months ago #86631 by Mihail Semerdzhiev
Replied by Mihail Semerdzhiev on topic Plugins in generic.php
On this lines, i dont have any content events or k2 events :(

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

  • Mihail Semerdzhiev
  • Mihail Semerdzhiev's Avatar Topic Author
  • Offline
  • New Member
More
14 years 2 months ago #86632 by Mihail Semerdzhiev
Replied by Mihail Semerdzhiev on topic Plugins in generic.php
I do it something wrong. I'm try everything but still cant load the plugins.

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

  • Pedro Alcaraz Mayor
  • Pedro Alcaraz Mayor's Avatar
  • Offline
  • New Member
More
13 years 6 months ago #86633 by Pedro Alcaraz Mayor
Replied by Pedro Alcaraz Mayor on topic Plugins in generic.php
This change has worked for me in the file /templates/&lt;YOUR-TEMPLATE&gt;/html/com_k2/templates/generic.php<br/>
<br/>
<br/>
<br/>
&lt;?php if($item-&gt;params-&gt;get('itemVideo') &amp;&amp; !empty($item-&gt;video)): ?&gt;
&lt;!-- Item video --&gt; &lt;a name="itemVideoAnchor" id="itemVideoAnchor"&gt;&lt;/a&gt;<br/>
<br/>
&lt;div class="itemVideoBlock"&gt;
&lt;?php
$params = &amp; JComponentHelper::getParams('com_k2');
$limitstart=0;
if (!empty($item-&gt;video) &amp;&amp; JString::substr($item-&gt;video, 0, 1) !== '{') {
$item-&gt;video = '&lt;div class="K2FeedVideo"&gt;'.$item-&gt;video.'&lt;/div&gt;';
}
else {
//$params-&gt;set('vwidth', $item-&gt;params-&gt;get('itemVideoWidth'));
$params-&gt;set('vwidth',320);
$params-&gt;set('vheight', intval(($item-&gt;params-&gt;get('itemVideoHeight')*320)/480));
$params-&gt;set('autoplay', $item-&gt;params-&gt;get('itemVideoAutoPlay'));
$params-&gt;set('vfolder', 'media/k2/videos');
if(JString::strpos($item-&gt;video, 'remote}')){
preg_match("#}(.*?){/#s",$item-&gt;video, $matches);
if(!JString::strpos($matches[1], 'http://}'))
$item-&gt;video = str_replace($matches[1], JURI::root().$matches[1], $item-&gt;video);
}
$dispatcher = &amp;JDispatcher::getInstance();
JPluginHelper::importPlugin ('content');
$item-&gt;text=$item-&gt;video;
$dispatcher-&gt;trigger ( 'onPrepareContent', array (&amp;$item, &amp;$params, $limitstart ) );
$item-&gt;video= '&lt;div class="K2FeedVideo"&gt;'.$item-&gt;text.'&lt;/div&gt;';
//echo '&lt;pre&gt;' . $item-&gt;description . '&lt;/pre&gt;';
}
?&gt;
&lt;?php if($item-&gt;videoType=='embedded'): ?&gt;
&lt;div class="itemVideoEmbedded"&gt;
&lt;?php echo $item-&gt;video; ?&gt;
&lt;/div&gt;
&lt;?php else: ?&gt;
&lt;span class="itemVideo"&gt;&lt;?php echo $item-&gt;video; ?&gt;&lt;/span&gt;
&lt;?php endif; ?&gt;<br/>
<br/>
&lt;?php if($item-&gt;params-&gt;get('itemVideoCaption') &amp;&amp; !empty($item-&gt;video_caption)): ?&gt;
&lt;span class="itemVideoCaption"&gt;&lt;?php echo $item-&gt;video_caption; ?&gt;&lt;/span&gt;
&lt;?php endif; ?&gt;<br/>
<br/>
&lt;?php if($item-&gt;params-&gt;get('itemVideoCredits') &amp;&amp; !empty($item-&gt;video_credits)): ?&gt;
&lt;span class="itemVideoCredits"&gt;&lt;?php echo $item-&gt;video_credits; ?&gt;&lt;/span&gt;
&lt;?php endif; ?&gt;
&lt;/div&gt;
&lt;?php endif; ?&gt;
<br/>
<br/>
Pedro Alcaraz

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

More
10 years 10 months ago #86634 by TOTHOMweb
Replied by TOTHOMweb on topic Re: Plugins in generic.php
Tanks Pedro, that worked perfectly!

I used this cleared code (without <br/>):
Log in  or Create an account to join the conversation.