Author Topic: how can I embed joomla module inside Category Information?  (Read 7402 times)

titus1972

  • Beginner
  • *
  • Posts: 4
how can I embed joomla module inside Category Information?
« on: January 23, 2011, 22:33:25 pm »
How can I put a Joomla component within a categories description information? When I add a component to a virtuemart category page that component appears on every  category page in the store, e.g http://lovingtheplanet.com/index.php?option=com_virtuemart&page=shop.browse&category_id=55&Itemid=53&TreeId=26

Please note the flash image component is assigned only to one category (services) page yet it appears on every category in my store. So I am trying to embed the component into the category description. Can this be done? I am really stumped here.

zorkhh

  • Advanced
  • Jr. Member
  • *****
  • Posts: 245
    • vm-expert.com
Re: how can I embed joomla module inside Category Information?
« Reply #1 on: January 24, 2011, 09:10:58 am »
There are a lot of different ways how this could be solved. Your apporach will only work through a plugin that loads the module into the description and you have to trigger the plugin with the description.

You could also use nonumbers advanced module manager and add some PHP code where you check the category ID to the options.

I would suggest something else. We use this a lot and it is very flexible and easy to use. Add a module-tag to your Joomla-template that dynamically adds the category ID. This way, you have a module position for every category in your shop:

Code: [Select]
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />
You could add an IF-clause to check if you are on the browse page...

You now have a module position called for example "vmx_cat_100" (if your category ID is "100"). This way it is easy to add modules to different categories.

Check this blog-post for more information about this "trick": http://www.vm-expert.com/virtuemart-expert-blog/119-more-flexible-module-positions
Virtuemart Professional Support at http://www.vm-expert.com

Visit the large Virtuemart Group on Joomla.org: http://people.joomla.org/groups/viewgroup/30-Virtuemart.html

kleinbaas

  • Beginner
  • *
  • Posts: 34
Re: how can I embed joomla module inside Category Information?
« Reply #2 on: July 09, 2011, 04:08:33 am »
Thanks for the info. I needed a way to run code for a particular category only and your post was my starting point.

The reason I need to do this is for Google Remarketing. I was surprised that no-one else has posted about this on the Virtuemart forum so I thought I would let you know how I got on..

To make Google Remarketing work, Google needs to know if a user has visited a specific part of your website (the Gardening section in my case). I added the following code to the end of the virtuemart.php file (found in components/com_virtuemart). The code I bodged together finds the parent category id. You can then use an if statement to run code only if the parent id is the one you are interested in. The code also uses the current category id instead of the parent category id if the parent category id is 0 (if you are already in a top level category).

Note I have included the code just before and after my code in the following snippet so that you can see where it goes.

Code: [Select]
// Set debug option on/off
if (vmShouldDebug()) {  /*@MWM1: Log/Debug enhancements */
$end = utime();
$runtime = $end - $start;

include( PAGEPATH . "shop.debug.php" );
}

/* Get Parent Cat ID for Google Remarketing*/
$db = & JFactory::getDBO();

$q = "SELECT category_parent_id FROM #__vm_category_xref  WHERE category_child_id = ".$category_id;
$db->setQuery($q);
$parentIDList = $db->loadObjectList();
$parentID=$parentIDList[0]->category_parent_id;

if($parentID==0){
$parentID = $category_id;
}

/*echo $parentID;*/  //uncomment this to show the parentID on your page while you check it works

if($parentID ==3801){ //3801 is my gardening top level category, you need to change this for your site
?><!-- Google Code for Gardening Tools Remarketing List -->
// replace this line with the code from google, or other code you want to use
<?php
}
/* End Google Parent Cat Id...*/

}
$vm_mainframe->close();
?>


You can see this working here: http://www.bannerfieldtools.com/gardening. If I haven't run out of money you should see some gardening related ads on your travels (you can turn this off here: http://www.google.com/ads/preferences)

I would really appreciate it if someone could help me tidy this code up a bit. All suggestions welcome. Also, next step is to load in a file with the google code only if in the right category, so any advice on that also welcome.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10423
  • VirtueMart Version: 3+
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

mbit

  • Jr. Member
  • **
  • Posts: 323
Re: how can I embed joomla module inside Category Information?
« Reply #4 on: February 08, 2012, 13:07:05 pm »
Code: [Select]
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />
You now have a module position called for example "vmx_cat_100" (if your category ID is "100"). This way it is easy to add modules to different categories.
i copied the code in my browse.tpl.php . My category was 100, i set the module position on the vmx_cat_100 but nothing appears :/ i view the source and the  jdoc is still there.. no module included  . do i miss something here?
Code: [Select]
<jdoc:include type="module" name="vmx_cat_116" />

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10423
  • VirtueMart Version: 3+
Re: how can I embed joomla module inside Category Information?
« Reply #5 on: February 08, 2012, 18:04:44 pm »
Code: [Select]
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />
You now have a module position called for example "vmx_cat_100" (if your category ID is "100"). This way it is easy to add modules to different categories.
i copied the code in my browse.tpl.php . My category was 100, i set the module position on the vmx_cat_100 but nothing appears :/ i view the source and the  jdoc is still there.. no module included  . do i miss something here?
Code: [Select]
<jdoc:include type="module" name="vmx_cat_116" />

mbit, that code will need to be OUTSIDE of the component. in your template.

OR, use the modules anywhere like I suggested.

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

mbit

  • Jr. Member
  • **
  • Posts: 323
Re: how can I embed joomla module inside Category Information?
« Reply #6 on: February 08, 2012, 18:37:21 pm »
Code: [Select]
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />
You now have a module position called for example "vmx_cat_100" (if your category ID is "100"). This way it is easy to add modules to different categories.
i copied the code in my browse.tpl.php . My category was 100, i set the module position on the vmx_cat_100 but nothing appears :/ i view the source and the  jdoc is still there.. no module included  . do i miss something here?
Code: [Select]
<jdoc:include type="module" name="vmx_cat_116" />

mbit, that code will need to be OUTSIDE of the component. in your template.

OR, use the modules anywhere like I suggested.


you mean the joomla template?

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10423
  • VirtueMart Version: 3+
Re: how can I embed joomla module inside Category Information?
« Reply #7 on: February 08, 2012, 19:18:52 pm »
Code: [Select]
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />
You now have a module position called for example "vmx_cat_100" (if your category ID is "100"). This way it is easy to add modules to different categories.
i copied the code in my browse.tpl.php . My category was 100, i set the module position on the vmx_cat_100 but nothing appears :/ i view the source and the  jdoc is still there.. no module included  . do i miss something here?
Code: [Select]
<jdoc:include type="module" name="vmx_cat_116" />

mbit, that code will need to be OUTSIDE of the component. in your template.

OR, use the modules anywhere like I suggested.


you mean the joomla template?

YES
THIS
<jdoc:include type="modules" name="vmx_cat_<?php echo JRequest::getInt('category_id');?>" style="raw" />

would need to be above

<jdoc:include type="component">

OR< if you download the modules anywhere, you can put a module in an article, category description, or the categoryHeader.tpl

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

mbit

  • Jr. Member
  • **
  • Posts: 323
Re: how can I embed joomla module inside Category Information?
« Reply #8 on: February 09, 2012, 12:35:38 pm »
<?php echo vmCommonHTML::ParseContentByPlugins( '{loadposition demoposition' ); ?>
this works as well!

is there a way to make this work dynamic with the category id? instead of demoposition add
Code: [Select]
vmx_cat_<?php echo JRequest::getInt('category_id');?> any ideas for the cyntax?