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.

 

show a module on frontpage only (need help)

show a module on frontpage only (need help)

hi! i have been trying for 2 days now but just cant seem to get this to work.
i installed MetaMod v2.8c, and i am trying to display a module on the fontpage only and exclude some pages like checkout.index and account.index.

i use the following code:

Code:

if ($_GET['page'] != "checkout.index") {

return 70;
}

this did work for me, the module stopped showing on the checkout page, however when i try to exclude multiple pages it doesn't work. i used the following code for multiple pages.

Code:

if (($_GET['page'] != "shop.cart") || ($_GET['page'] != "checkout.index") || ($_GET['page'] != "account.index") || ($_GET['page'] != "shop.registration")) {

return 70;
}

am I doing something wrong? sad

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

Re: show a module on frontpage only (need help)

Hi phasr,

what you are attempting is called "boolean algebra" and it's so easy to make mistakes!

Think about this for a moment... if you say "A != 1 or A != 2", then there's no value of A that can satisfy both conditions.

Instead, you want "NOT (A == 1 or A == 2)".

So try this:

$page = $_GET['page'];
if (! ($page == "shop.cart" or $page == "checkout.index" or $page == "account.index" or $page == "shop.registration")) return 70;


Personally I'd do this with JomGenius:

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype starts with none of shop.cart, checkout, account, shop.registration")) return 70;

Or, if it's easier to specify the list of page types where you want it to appear:

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype = any of frontpage, shop.product_details, shop.search, shop.infopage")) return 70;


You can find out more about JomGenius here:

http://www.metamodpro.com/jomgenius/par … andcheckvm

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

Re: show a module on frontpage only (need help)

1 word, perfect!! ^^ thank you sooo very mush this solved my problem!


metamodguy wrote:

Hi phasr,

what you are attempting is called "boolean algebra" and it's so easy to make mistakes!

Think about this for a moment... if you say "A != 1 or A != 2", then there's no value of A that can satisfy both conditions.

Instead, you want "NOT (A == 1 or A == 2)".

So try this:

$page = $_GET['page'];
if (! ($page == "shop.cart" or $page == "checkout.index" or $page == "account.index" or $page == "shop.registration")) return 70;


Personally I'd do this with JomGenius:

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype starts with none of shop.cart, checkout, account, shop.registration")) return 70;

Or, if it's easier to specify the list of page types where you want it to appear:

$vm = JomGenius("virtuemart");
if ($vm->check("pagetype = any of frontpage, shop.product_details, shop.search, shop.infopage")) return 70;


You can find out more about JomGenius here:

http://www.metamodpro.com/jomgenius/par … andcheckvm

Cheers,
Stephen

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10772
Newest User:
alton29318
Members Online:
0
Guests Online:
197

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