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

Creating a mod-position on product details page that can be assigned by category

Started by Genius WebDesign, June 05, 2012, 02:23:33 AM

Previous topic - Next topic

Genius WebDesign

Hi,

I read this article about module positions in Virtuemart 2:
http://www.kaizenmediaworks.com/vmart-mods.pdf

According to the author it is possible to add a module position on the product details page that can be assigned by category using this code:

<?php if (JRequest::getVar('view')=='productdetails') { ?>
<jdoc:include type="modules" name="productbycat<?php echo
JRequest::getInt('virtuemart_category_id',0); ?>" />
<?php } ?>

As it's explained "it creates a module position on product details page called productbycat# with # being the current
category id."

I have tried to put this code into the default.php file in my template folder under /productdetails and assigning productbycat# as module position in the module setup but nothing shows..

I'm pretty new at this so I'm sure its just me not understanding this correctly.
Can someone tell me exactly what to do to make this work?




Genius WebDesign

I also tried to put in this code:

<?php if (JRequest::getVar('view')=='productdetails') { ?>
<jdoc:include type="modules" name="productdetails" />
<?php } ?>

which should create a module position called "productdetails" where I can show a module on all product detail pages, but it doesnt work for me..
I guess I'm inserting the code in the wrong php file, but I would think that the position should be placed in the "default.php" file loading the product details page.

I hope someone can help me on this one.

techmodule

Quote from: fabelmik on June 05, 2012, 02:29:11 AM
I also tried to put in this code:

<?php if (JRequest::getVar('view')=='productdetails') { ?>
<jdoc:include type="modules" name="productdetails" />
<?php } ?>

which should create a module position called "productdetails" where I can show a module on all product detail pages, but it doesnt work for me..
I guess I'm inserting the code in the wrong php file, but I would think that the position should be placed in the "default.php" file loading the product details page.

I hope someone can help me on this one.
I have the same problem, any one can explain this code, what file to included

Genius WebDesign

Hi techmodule,

My "solution" was to instead use a Joomla-plugin called "Modules Anywhere":
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/embed-a-include/6402

Just install the plugin, and enable "Joomla plugins" in Virtuemart config. and you are set to go.


When it´s installed you just add the tag:  {module #}       (#=your module ID) anywhere you like.
You can also assign module-positions. The tag for this depends on what setting you make in the MA-plugin, though. It could be: {modulepos #}       (#=your new module-position)


In the override default.php file you can do it by using this example:

Find a suitable place for the module you want placed and wrap it in a div, like this:    <div> {module #} </div>
It´s a very good thing to use div-wraps because you can then assign classes or IDs for CSS styling, like this:  <div class="my-div-class"> {module #} </div>

The MA-plugin works in all Joomla articles aswell, which means that you can add the code litterally anywhere you want.. Actually I think that the MA-plugin installer also includes an editor-button, so that you can quickly add MA-tags in articles and custom HTML with a simple click.

Agaton

/*   Calling Joomla Module in Virtuemart product page */
   $modules =&  JModuleHelper::getModules('position-4');
   foreach ($modules as $module)
   {
  echo JModuleHelper::renderModule($module);
   }


This code works perfectly to add modules to the default.php of productdetails templates in virtuemart 2.x

baggiesmad

Works
Quote from: spike1968 on October 18, 2013, 18:21:06 PM
/*   Calling Joomla Module in Virtuemart product page */
   $modules =&  JModuleHelper::getModules('position-4');
   foreach ($modules as $module)
   {
  echo JModuleHelper::renderModule($module);
   }


This code works perfectly to add modules to the default.php of productdetails templates in virtuemart 2.x

Works fine on VM3! Thanks

Agaton