Author Topic: Parsing a plugin inside a view  (Read 4208 times)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Parsing a plugin inside a view
« on: October 24, 2011, 18:31:50 pm »
Hi,
In the former version there was a "trick" like this one:
Code: [Select]
<?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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #1 on: October 24, 2011, 20:16:35 pm »
there is a setting to turn on content plugins, have you tried that?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #2 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.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #3 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?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #4 on: October 24, 2011, 23:52:41 pm »
What do you mean?
Isn't "modal" something integral in Joomla?

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #5 on: October 25, 2011, 02:01:08 am »
what plugin are you trying to use?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #6 on: October 25, 2011, 05:56:46 am »
Let's say "sigplus", for instance.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #7 on: October 25, 2011, 15:42:28 pm »
have you tried the syntax in the product description?

{gallery}birds1{/gallery}
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #8 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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #9 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.

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #10 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...

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10362
  • VirtueMart Version: 3+
Re: Parsing a plugin inside a view
« Reply #11 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?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

drizzt99

  • Jr. Member
  • **
  • Posts: 89
[SOLVED] Re: Parsing a plugin inside a view
« Reply #12 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...

drizzt99

  • Jr. Member
  • **
  • Posts: 89
Re: Parsing a plugin inside a view
« Reply #13 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:
Code: [Select]
if ( VmConfig::get('enable_content_plugin',0)) {
// add content plugin //
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');

Here's the part I've added:
Code: [Select]
/* 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:
Code: [Select]
$product->text = $product->product_desc;
To this:
Code: [Select]
$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...