Keyword

Inject HTML including plugins in to K2 item fulltext - help please?

More
13 years 6 months ago #94979 by dex
Hi

 

I'm in over my head, but hopefully someone can point me in the right direction?

 

I'm trying to automatically display a remote video (to members only) before each K2 item's fulltext in Item display. I have the video ID stored in an extra field called Media.

 

So I added this code to models/item.php in function prepareItem:

if($extraField->name == "Media"):        $mediavalue = $extraField->value; endif;

$item-&gt;fulltext = "{jugaaccess Members},{jwplayer}&amp;botr.file=http://content.bitsontherun.com/players/" . $mediavalue . "-UGxbzzKa.js{/jwplayer},{/jugaaccess}<br />" . $item->fulltext;


 

This does add the HTML, but in Item Display I see it exactly as shown below - the code is NOT interpreted by the relevant plugins.

 

&lt;div class="itemIntroText"&gt;{jugaaccess Members},{jwplayer}&amp;botr.file=http://content.bitsontherun.com/players/FAEoO6dC-UGxbzzKa.js{/jwplayer},{/jugaaccess} <br />The fulltext description....</div>

How do I get the plugins to work on it?

Can you tell me where in my coding infancy I have gone wrong?thanks very muchDex


FAEoO6dC

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

More
13 years 6 months ago #94980 by william white
Your in over my head as well. Have you tried using your code in the item.php of an override which would be sending the final output to be rendered to the browzer and where plugins seem to work?

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

More
13 years 6 months ago #94981 by dex
Ah, why didnt i think of that. Thanks, it does work

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

More
13 years 5 months ago #94982 by yonglas
Hi can you upload your solution?

i also trying to insert

{jugaaccess 20}some text{/jugaaccess}to item.php and it seems that the juga content plugin dosnt workthanks

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

More
13 years 4 months ago #94983 by yonglas
can you give a sample for this?
how can i control on the final output?William White said:Your in over my head as well. Have you tried using your code in the item.php of an override which would be sending the final output to be rendered to the browzer and where plugins seem to work?

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

More
13 years 4 months ago #94984 by BBC
Maybe

{/jwplayer},{/jugaaccess}

 

as

/{jwplayer/}/{jugaaccess/} 

 

I will test this, for some other Joomla plugins and other needs in future.

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

More
13 years 4 months ago #94985 by yonglas
:(  its didn't change anything...

thanks anyway.

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

More
13 years 4 months ago #94986 by BBC
It needs to bi studied in other PHP files how Joomla plugins are called. (not template PHP files)

Maybe to study how Sobi does it. If it is not so huge different in coding, etc...

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

More
13 years 3 months ago #94987 by dex
OK I found that the HTML template override worked. I added com_k2/templates/[myK2templatename]/item.php to the html folder in my Joomla template, and assigned the K2 template to my categories.

 

Then in item.php at approx line 254, I replaced

 

&lt;?php if($this-&gt;item-&gt;params-&gt;get('itemExtraFields') &amp;&amp; count($this-&gt;item-&gt;extra_fields)): ?&gt;      &lt;!-- Item extra fields --&gt;      &lt;div class="itemExtraFields"&gt;          &lt;h3&gt;&lt;?php echo JText::_('Additional Info'); ?&gt;&lt;/h3&gt;          &lt;ul&gt;            &lt;?php foreach ($this-&gt;item-&gt;extra_fields as $key=&gt;$extraField):?&gt;            &lt;li class="&lt;?php echo ($key%2) ? "odd" : "even"; ?&gt; type&lt;?php echo ucfirst($extraField-&gt;type); ?&gt; group&lt;?php echo $extraField-&gt;group; ?&gt;"&gt;                &lt;span class="itemExtraFieldsLabel"&gt;&lt;?php echo $extraField-&gt;name; ?&gt;:&lt;/span&gt;                &lt;span class="itemExtraFieldsValue"&gt;&lt;?php echo $extraField-&gt;value; ?&gt;&lt;/span&gt;            &lt;/li&gt;            &lt;?php endforeach; ?&gt;            &lt;/ul&gt;        &lt;div class="clr"&gt;&lt;/div&gt;      &lt;/div&gt;      &lt;?php endif; ?&gt;

 

with

 

&lt;?php if($this-&gt;item-&gt;params-&gt;get('itemExtraFields') &amp;&amp; count($this-&gt;item-&gt;extra_fields)): ?&gt;      &lt;!-- Item extra fields --&gt;      &lt;div class="itemExtraFields"&gt;          &lt;h3&gt;&lt;?php echo JText::_('Additional Info'); ?&gt;&lt;/h3&gt;          &lt;ul&gt;            &lt;?php foreach ($this-&gt;item-&gt;extra_fields as $key=&gt;$extraField):?&gt;                &lt;?php // *DM* starts - Auto-add image (non-members) or video (members) to fulltext                if($extraField-&gt;name == "Duration"):                     $durationlabel = $extraField-&gt;name; $durationvalue = $extraField-&gt;value;                 endif;                 if($extraField-&gt;name == "File size"):                     $filesizelabel = $extraField-&gt;name; $filesizevalue = $extraField-&gt;value;                 endif;                 if($extraField-&gt;name == "Media"):                     $medialabel = $extraField-&gt;name; $mediavalue = $extraField-&gt;value;                 endif;                 if($extraField-&gt;name == "Player"):                     $playerlabel = $extraField-&gt;name; $playervalue = $extraField-&gt;value;                 endif;            // *DM* Set base paths for video and thumbnails             $videobase = "video.joomlarulez.com/players/";            $thumbnailbase = "video.joomlarulez.com/thumbs/";            $thumbsize = "180";             $item->fulltext = "{jugaaccess !Members}<img src='" . $thumbnailbase . $mediavalue . "-180.jpg' alt='Become a member to view this video' title='Become a member to view this video' />{/jugaaccess}<br />{jugaaccess Members},{jwplayer}&botr.file=" . $videobase . $mediavalue . "-" . $playervalue . ".js{/jwplayer},{/jugaaccess}<br />" . $item->fulltext;             // *DM* ends  ?>            <!-- *DML* dont display thumbnail, video link, player, contributor * -->            <?php if(!($extraField->name == "Thumbnail") && !($extraField->name == "Media") && !($extraField->name == "Contributor") && !($extraField->name == "Player")): ?>            <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">                <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>                <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>            </li>            <?php endif; ?>            <?php endforeach; ?>            </ul>        <div class="clr"></div>      </div>      <?php endif; ?>

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

More
13 years 3 months ago #94988 by yonglas
hi dex , thank a lot, i will try that

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


Powered by Kunena Forum