News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Parsing a plugin inside a view

Started by drizzt99, October 24, 2011, 18:31:50 PM

Previous topic - Next topic

drizzt99

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

PRO

there is a setting to turn on content plugins, have you tried that?

drizzt99

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.

PRO

so can you change the class="modal" to whatever the plugin class is? in the product page?

drizzt99

What do you mean?
Isn't "modal" something integral in Joomla?

PRO


drizzt99


PRO

have you tried the syntax in the product description?

{gallery}birds1{/gallery}

drizzt99

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

PRO

you can put it in the view itself, It will be a fixed gallery though, and not dynamic.


drizzt99

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...

PRO

I just enabled joomla plugins in vmart admin.

Then used mvthubnails plugin and it worked.

WHAT triggers the plugin?

drizzt99

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...

drizzt99

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...