VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: drizzt99 on October 24, 2011, 18:31:50 PM

Title: Parsing a plugin inside a view
Post by: drizzt99 on October 24, 2011, 18:31:50 PM
Hi,
In the former version there was a "trick" like this one:
<?php echo vmCommonHTML::ParseContentByPlugins"{yourplugincodehere}" ); ?>
It doesn't seem to work on VM2.
Any insight on this one? Will it be supported?
Thanks,
Yonatan
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 24, 2011, 20:16:35 PM
there is a setting to turn on content plugins, have you tried that?
Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 24, 2011, 20:20:20 PM
That's parsing in the description.
I want to parse the plugin in the view file itself.
Is this possible?
My final aim in this is to integrate a gallery plugin in my product pages.
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 24, 2011, 20:28:59 PM
so can you change the class="modal" to whatever the plugin class is? in the product page?
Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 24, 2011, 23:52:41 PM
What do you mean?
Isn't "modal" something integral in Joomla?
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 25, 2011, 02:01:08 AM
what plugin are you trying to use?
Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 25, 2011, 05:56:46 AM
Let's say "sigplus", for instance.
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 25, 2011, 15:42:28 PM
have you tried the syntax in the product description?

{gallery}birds1{/gallery}
Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 25, 2011, 19:05:46 PM
Hi,
It will work. I tried it before.
Can I put two instances of the "description"?
One with the original content and one with (plugin} only?

What if I want a plugin NOT in the description? Like add a plugin in the view file itself...

Another thing which could have helped - I cannot find modules and plugins for VM 2 as an example to learn from, and I'm afraid the wiki is not so clear to me... is there a working module/plugin I can learn from?

Thanks,
Yonatan
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 25, 2011, 19:25:17 PM
you can put it in the view itself, It will be a fixed gallery though, and not dynamic.

Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 25, 2011, 23:17:52 PM
Ok,
Here's what I did:
- multithumb is supposed to create a thumbnail from every image I enter a content item.
- I have it installed on my system.
- I add an image to the content and it is not being handled by multithumb even though I have enabled joomla plugins in product...
Title: Re: Parsing a plugin inside a view
Post by: PRO on October 26, 2011, 02:11:13 AM
I just enabled joomla plugins in vmart admin.

Then used mvthubnails plugin and it worked.

WHAT triggers the plugin?
Title: [SOLVED] Re: Parsing a plugin inside a view
Post by: drizzt99 on October 26, 2011, 06:18:32 AM
Hi,
Ok, I got the problem here.
When I add the images to the description, I get the plugin to work.
When I add the images using PHP (i.e. dynamically from the DB), it doesn't work.
The reason is that Mthumb is a content plugin that works "onPrepareContent" and when I add the images using PHP it's "onAfterRender", so the plugin does not apply on the images I add...
Title: Re: Parsing a plugin inside a view
Post by: drizzt99 on October 26, 2011, 07:37:12 AM
I got it to work now dynamically by adding the images via the view.html.php.
Here's what I did:

After this part:
if ( VmConfig::get('enable_content_plugin',0)) {
// add content plugin //
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');


Here's the part I've added:
/* add image gallery to the product description - multithumb MUST be enabled*/
//create a DB var
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__virtuemart_product_medias WHERE virtuemart_product_id = $virtuemart_product_id ";
$db->setQuery($query);
$db->query();
$results = $db->loadObjectList();

//Search for the product's images\
$i = 0;
$product->text = '<p style="height:200px; text-align: center;">';
foreach ($results as $result){

$query = "SELECT * FROM #__virtuemart_medias WHERE virtuemart_media_id = $result->virtuemart_media_id";
$db->setQuery($query);
$db->query();
$img = $db->loadObjectList();

$images[$i][img] = '<img src="' . $img[0]->file_url . '" alt="gallery" class="productgallery"/>';
$images[$i][thumb] = '<img src="' . $img[0]->file_url_thumb . '" alt="gallery"/>';
$product->text .= $images[$i][img];
}
$product->text .= "</p>";


And below this I changed:
$product->text = $product->product_desc;

To this:
$product->text .= $product->product_desc;

It now shows the "extra images" in the content and renders them using multithumb in a nice gallery.

You can probably think of a better way to to that.  I just don't know VM's code too well...