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.

 

Metatemplate pro + metamod pro failing

Metatemplate pro + metamod pro failing

Hello

I just got both modules to fix some issues inside a virtuemart cattegories, I have a template for every top virtuemart categorie, so I am using metatemplatepro to change the template according to the parent category, and I am using metatemplatepro to display a custom menu for every top category too, both modules seems to work fine but after few levels deep both stop working

Example:
http://www.disandina.com/web/index.php? … ;Itemid=16

Try to go one category or product deeper and you will see a different template, also try to go back 1 category and you will see that the right template is rendered.

The metatemplate pro rule only condition is: Ancestor Category id(s)= 11(the parent category on the example) and the rules on metamod pro are:

$vm = JomGenius("virtuemart");

if ($vm->check("ancestor_category_ids = 8"))return 42;
if ($vm->check("ancestor_category_ids = 9"))return 45;
if ($vm->check("ancestor_category_ids = 10"))return 48;
if ($vm->check("ancestor_category_ids = 11"))return 51;
if ($vm->check("ancestor_category_ids = 12"))return 53;
if ($vm->check("ancestor_category_ids = 158"))return 66;
if ($vm->check("ancestor_category_ids = 182"))return 70;

Also I need your help with some instructions on how to hide a module using the same rules above

could you please help me ASAP? I will really appreciate it... my deadline to deliver this project was yesterday and now I have an angry client


Regards

edsadr
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Metatemplate pro + metamod pro failing

[I followed this up in an e-mail -- repeating the information here for general info]

Hi edsadr,

The check for ancestor ids was capped at 5 levels, for performance reasons. I hadn't met any VM setups that used more than this, and it seemed a sensible default.

I'm going to give you some code that you can use to modify MetaTemplate itself. This is easier than providing some work-around code to put inside the PHP box, which would get really complex. It also means that it will work with the GUI controls for VM ancestor categories in MetaTemplate Pro.

The code that controls this is in /components/com_metatemplate/jomgenius/virtuemart.php, in the function _categoryInfoForProductId( $ids ) and _categoryInfoForCategoryId( $id ).

The 1st function is used for retrieving the ancestor ids when you're on a product page (and have the product id) and the 2nd is used when you are on a category page and have the category id.

In the case of categories, the relevant code is:

        $query = "select distinct
            cx1.category_child_id as c1,
            vmc1.category_name as n1,
            cx2.category_child_id as c2,
            vmc2.category_name as n2,
            cx3.category_child_id as c3,
            vmc3.category_name as n3,
            cx4.category_child_id as c4,
            vmc4.category_name as n4,
            cx5.category_child_id as c5,
            vmc5.category_name as n5
           
            from
            #__vm_category_xref cx1
            left outer join #__vm_category_xref cx2 on cx1.category_parent_id = cx2.category_child_id
            left outer join #__vm_category_xref cx3 on cx2.category_parent_id = cx3.category_child_id
            left outer join #__vm_category_xref cx4 on cx3.category_parent_id = cx4.category_child_id
            left outer join #__vm_category_xref cx5 on cx4.category_parent_id = cx5.category_child_id
            left outer join #__vm_category vmc1 on vmc1.category_id = cx1.category_child_id
            left outer join #__vm_category vmc2 on vmc2.category_id = cx2.category_child_id
            left outer join #__vm_category vmc3 on vmc3.category_id = cx3.category_child_id
            left outer join #__vm_category vmc4 on vmc4.category_id = cx4.category_child_id
            left outer join #__vm_category vmc5 on vmc5.category_id = cx5.category_child_id
            where cx1.category_child_id = $category_id";


It's easy enough to add extra levels by editing this code in place, in the component.

e.g. to add 2 extra levels:

        $query = "select distinct
            cx1.category_child_id as c1,
            vmc1.category_name as n1,
            cx2.category_child_id as c2,
            vmc2.category_name as n2,
            cx3.category_child_id as c3,
            vmc3.category_name as n3,
            cx4.category_child_id as c4,
            vmc4.category_name as n4,
            cx5.category_child_id as c5,
            vmc5.category_name as n5,

            cx6.category_child_id as c6,
            vmc6.category_name as n6,
            cx7.category_child_id as c7,
            vmc7.category_name as n7

           
            from
            #__vm_category_xref cx1
            left outer join #__vm_category_xref cx2 on cx1.category_parent_id = cx2.category_child_id
            left outer join #__vm_category_xref cx3 on cx2.category_parent_id = cx3.category_child_id
            left outer join #__vm_category_xref cx4 on cx3.category_parent_id = cx4.category_child_id
            left outer join #__vm_category_xref cx5 on cx4.category_parent_id = cx5.category_child_id

            left outer join #__vm_category_xref cx6 on cx5.category_parent_id = cx6.category_child_id
            left outer join #__vm_category_xref cx7 on cx6.category_parent_id = cx6.category_child_id


            left outer join #__vm_category vmc1 on vmc1.category_id = cx1.category_child_id
            left outer join #__vm_category vmc2 on vmc2.category_id = cx2.category_child_id
            left outer join #__vm_category vmc3 on vmc3.category_id = cx3.category_child_id
            left outer join #__vm_category vmc4 on vmc4.category_id = cx4.category_child_id
            left outer join #__vm_category vmc5 on vmc5.category_id = cx5.category_child_id

            left outer join #__vm_category vmc6 on vmc6.category_id = cx6.category_child_id
            left outer join #__vm_category vmc7 on vmc7.category_id = cx7.category_child_id


            where cx1.category_child_id = $category_id";


The code changes for the _categoryInfoForProductId function will be very similar.

Then in function  _allCategoryStuff( $type )  there's this line:

for ( $i = 1; $i <= 5; $i++ ) {

You need to change the "5" to whatever number of levels you are pulling out in the parent category id thing. In this case, 7.

Then in function _topLevelStuff( $type ) there's this line:

for ($i = 5; $i >= 1; $i-- ) {

... change the "5" to the new number of levels, as in the last example.


Since you are using both MetaTemplate and MetaMod, this code should go in MetaTemplate's version of the JomGenius code, and this will be used by both products.

To hide a module, since you have MetaMod Pro, you can do the following:

// hide module 42 on ancestor category 8:
$vm = JomGenius("virtuemart");
if ($vm->check("ancestor_category_ids = 8")) {
  $changes->mod(42)->disable();
}

Hope that helps,
Best regards,
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
3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11515
Newest User:
velis415
Members Online:
0
Guests Online:
190

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