VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: Gros Bed on October 20, 2015, 13:41:51 PM

Title: Short code or activate pulgin in short description
Post by: Gros Bed on October 20, 2015, 13:41:51 PM
Hello!

I'm trying to use short code in order to use a mp3 plugin in the short description. I'm in Joomla! 2.5.28, Virtuemart 2.0.26d.

Before this version I used this hack :

                   <?php
                    
if (!empty($product->product_s_desc)) {
                    
?>

                    <p class="product_s_desc">
                        <?php
                        
echo JHTML::_('content.prepare'$product->product_s_desc);
                        echo 
shopFunctionsF::limitStringByWord($product->product_s_desc400'...')
                        
?>

                        </p>


But now it's not working.

Does somebody know how to activate plugin in short description ?

Note: In my description it's OK, but I want to have a mp3 sample in the category page.

Thanks.

Alexandre
Title: Re: Short code or activate pulgin in short description
Post by: Studio 42 on October 20, 2015, 22:17:09 PM
Hi,
If your code not work, then check here for the "long" version style.

Better to give the link to Joomla doc https://docs.joomla.org/Triggering_content_plugins_in_your_extension
Do not forget that now you have context verified in some plugin. You need to check the plugin code to know if you need to set a context.
Title: Re: Short code or activate pulgin in short description
Post by: Gros Bed on October 21, 2015, 09:00:58 AM
Thanks for the link.

That is working when I did not put the limitStringByWord line.

         
<?php // Product Short Description
   
if(!empty($product->product_s_desc)) { ?>

      <p><span class="product_s_desc">
         <?php echo JHTML::_('content.prepare'$product->product_s_desc?>
      </span></p>
<?php ?>



The loading of my page is taking more time but I have now my mp3 sample on the category page : http://bols-chantants.com/fr/boutique/bol-chantant-tibetain



Title: Re: Short code or activate pulgin in short description
Post by: Studio 42 on October 21, 2015, 14:17:48 PM
If you need to speedup your call you can add your own plugin type and add a function for this case only.

You can use the code in your template /html/com_virtuemart/category/default.php without adding any hacks in Virtuemart.

JPluginHelper::importPlugin('mp3');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onMusicPrepare', array($product));
echo $product->product_s_desc;

YOu need to do you own plugin and add to the plugins/mp3 folder.

eg. for plugin audio.php
class plgMp3Audio extends JPlugin
{

/**
* add mp3 player/sound script and html
*/
public function onMusicPrepare(&$product)
{
// your code here to modify short desc
}
}