Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

[solved] VirtueMart Pagination and Metamod

[solved] VirtueMart Pagination and Metamod

I'm working on an old Joomla version 1.5.26 site that has VirtueMart version 1.1.4 and MetaMod v2.12. The problem involves the VirtueMart pagination. The site currently resides on a private WAMP server on my own computer.

There was a discussion about this issue a few years ago on this forum. See
Virtuemart pagination causing Metamod modules to disappear. Unfortunately the solution was not published. Stephen wrote only, "Mark got it working."

I have two MetaMod modules that in turn display two Custom HTML modules only on the product_details pages of product categories as determined by the settings in the MetaMod Menu Assignment panel.

The form of the PHP code in the MetaMod module is simply:

Code:

$vm = JomGenius("virtuemart");

if ($vm->check("pagetype not = shop.browse")
and $vm->check("pagetype = shop.product_details"))
return XXX;

where XXX is the unique ID number of the module to be displayed. If site visitors are browsing a category page, the module will not be displayed. If visitors go to a page displaying product details, the correct module displays as expected. If the visitor then goes to the Previous Product or the Next Product using the VirtueMart pagination, the wrong module is displayed in some cases.

If the Menu Assignment for Metamod Module A is Menu Item A, the product detail pages directly linked from the category A page and the other product detail pages reached through the VirtueMart pagination will correctly display Custom HTML module A.

If the Menu Assignment for Metamod Module B is Menu Item B, the product detail pages directly linked from the category B page will display Custom HTML module B. The product detail pages reached through the VirtueMart pagination from the B category products will incorrectly display Custom HTML module A. If I disable Metamod Module A only, no module is displayed on the category B products reached through the VirtueMart pagination links.

I thought of using the category ID but the MetaMod debugger shows JRequest::getVar('category_id') == NULL for the pages reached through the VirtueMart pagination.

Is there a solution to correct this problem?

Charles

cmb
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: [solved] VirtueMart Pagination and Metamod

Hi Charles,

If I understand you correctly (and thanks for the comprehensive write-up of the problem) then you are relying in part on Joomla's Itemid (menu item) assignment to target the modules. The problem, as you have found, is that paging through VM items does not always have the desired effect on the ItemID. I think you are saying above that sometimes paging through VM items keeps the same menu item that you entered on, but other times it does not.

The answer is to not rely on menu items smile

You are on the right track with deciding to try doing it by category, if the 2 different modules are relevant to 2 distinct categories.

The only issue you had was in how to detect the category ID. The JRequest method is not going to work. Luckily JomGenius has the ability to do exactly this for you. You can retrieve the category ID like this:

$vm = JomGenius("virtuemart");
$catid = $vm->info("category_id");

Or, you can check the category id directly like this:

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype = shop.product_details")
  and $vm->check("category_id = 3"))
return XXX;
if ($vm->check("pagetype = shop.product_details")
  and $vm->check("category_id = 4"))
return YYY;

To just get MetaMod to output what it thinks is the category id for any given item, you can do this (just to check it's working right):

$vm = JomGenius("virtuemart");
echo "VM category: " . $vm->info("category_id") . "<br/>";

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] VirtueMart Pagination and Metamod

metamodguy wrote:

The answer is to not rely on menu items...

Thank you, Stephen. I edited my code to use the JomGenius method. Not everything worked correctly, though, until I changed the Menu Assignments from the particular menu item to All Menus.

Charles

cmb
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: [solved] VirtueMart Pagination and Metamod

Brilliant, well done. You've overcome the VM Itemid bogey smile

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10137
Newest User:
lexispoker1
Members Online:
0
Guests Online:
327

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked