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.

 

JomGenius and Virtuemart - mulitple page tests fail

JomGenius and Virtuemart - mulitple page tests fail

Using:-
VM 1.1.6
Joomla 1.5.22
Metamod 2.6
Metamod pro 2.6
JomGenius 5 (says 5 but this was included in the last download I did today! and I thought it should be 6 as the != function works for a page test.)

Problem - Multiple page tests are not working


Using code:-

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype != shop.cart, shop.product_details") ) return 52;

The module still displays on all pages.


Using code:-
$vm = JomGenius("virtuemart");
if ($vm->check("pagetype != shop.cart") ) return 52;

The test works and Module does not display in shop.cart

I thought that you could specify the different pages separated with commas??

I can resort to my old method of testing for multiple VM pages (see below) but it seemed to make sense to use the new JomGenius method:-

if ($option == "com_virtuemart") {
$page = JRequest::getVar("page");
}
$hidemodule = ($page == "shop.cart" or $page == "checkout.index" or $page == "shop.product_details");
if (!$hidemodule) return 52;


Can you suggest what I might be doing wrong?

Kind regards
Andrew

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

Re: JomGenius and Virtuemart - mulitple page tests fail

Hi Andrew,

I think you have stumbled across the reason why I did not include "!=" in the first versions of JomGenius. It's a complex piece of logic that's only made worse when you add negation. I eventually decided to add it, but it ends up not looking logical (even though it is, strictly speaking).

Confused yet?  ;-)

Ok, here's what's going on:

- when you use != to compare to a single item, it works as you would expect.
- when you use != to compare to more than one item, it appears to fail.

- the logic of the comparisons is able to cope with a list of items on both sides of the comparison operator (the =, !=, <, >, etc).

- if you don't specify "any of", "all of" or "none of" before the list on either side of the comparison operator, then JomGenius assumes "any of".

So "pagetype != shop.cart" gets read as "any of pagetype != any of shop.cart".

Now, there's only 1 item on each side, so it's a straight comparison, and that works as you would expect. (pagetype only ever returns one item - some other keywords can return a list of items, e.g. the contents of the shopping cart)

Let's look at what happens if there's more than 1 item in the list on the right:

"pagetype != shop.cart, shop.product_details"

This equates to "any of pagetype != any of shop.cart, shop.product_details"

So JomGenius checks:
pagetype != shop.cart ?
OR
pagetype != shop.product_details ?

If the pagetype was shop.cart, then the check succeeds (cos it wasn't shop.product_details), and if the pagetype is shop.product_details then it succeeds because it wasn't shop.cart. No matter what the pagetype is, it's always going to succeed, as there's no way for the rule to "fail" (equate to false).

The right way?

The right way to do this is to say:

if ($vm->check("pagetype = none of shop.cart, shop.product_details") ) return 52;


I hope I didn't confuse you too much!

Cheers,
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
3328 Posts
User info in posts
Administrator has disabled public posting

Re: JomGenius and Virtuemart - mulitple page tests fail

Works Perfectly

Many thanks. Metamod and metamod pro are brilliant modules and I would not be without them!!!!!

I new it had to be me, and thought that my use of the "!=" comparison looked somewhat suspicious with 2 tests to perform.

Many thanks for your reply, it is really appreciated.

Kind regards
Andrew

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

Re: JomGenius and Virtuemart - mulitple page tests fail

You're welcome,

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
3328 Posts
User info in posts
Administrator has disabled public posting

Re: JomGenius and Virtuemart - mulitple page tests fail

Hi, Metamodguy, I'm Brazilian, I downloaded your module Metamodfree, I'm trying to configure it to hide modules on virtuemart, the pages frontpage, checkout, shop.cart, and other pages of virtuemart, but im having great difficulties to understand how to make it work , I urge you to help me solve my doubts this, because I need to do that much work for the site of my clients e-commerce. I am using the following code to hide virtuemart modules, correct me if I'm wrong the way I'm doing:

JomGenius $ vm = ("virtuemart") / / need this at the start of EVERY rule
if ($ vm-> check ("pagetype not = frontpage shop.cart, shop.product_details, account.index")) return 144;

linhos
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: JomGenius and Virtuemart - mulitple page tests fail

You will need to buy the metamodpro plugin in order to achieve the removal of items and no empty html modules still being displayed.  It IS well worth the very small fee that is charged!!!

Code:

if ($core_genius->check("pagetype not = frontpage")) {


$vm = JomGenius("virtuemart");

if ($vm->check("pagetype = none of checkout.index#1,checkout.index#2,checkout.index#3,checkout.index#4") ) return nnn;
}

where nnn is either the module position or the module ID

This should give you a good starting point, it is the use of the term none-of rathe than "not=" that is causing you some issues.

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

Re: JomGenius and Virtuemart - mulitple page tests fail

Yes, like quorvia said you have to be careful about the syntax if you are trying to exclude more than one item.

If you are just comparing 1 item to exclude you can use "!= ..." or "not = ...".

If you are comparing more than one item to exclude you have to use "= none of ..."

Cheers,
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
3328 Posts
User info in posts
Administrator has disabled public posting

Re: JomGenius and Virtuemart - mulitple page tests fail

Tk vry much, its works perfecli now, cheers! smile

linhos
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4421
Newest User:
rajajudi14
Members Online:
0
Guests Online:
181

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