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.

 

Virtuemart Categories

Virtuemart Categories

Hello,

Please would you help me. I have only ever used metaMod once before, and find it rather confusing smile

On my clients site, I am wanting to have a different banner on each Virtuemart category. This is what I have got inside the MetaMod Module:

Code:

$vm = JomGenius("virtuemart");

if ( $vm->check("pagetype = category") ) {
    $category_id = $vm->info( "category_id" );
/* when browsing a specific category on browse page (e.g. category 2) */


if ($category_id == “27”) $img = "/images/Crockery_Banner.jpg";
if ($category_id == “28”) $img = "/images/Royal_Porcelain_Crockery_Banner.jpg";
if ($category_id == “29”) $img = "/images/Continental_Crockery_Banner.jpg";
if ($category_id == “30”) $img = "/images/Glasses_Banner.jpg";
if ($category_id == “31”) $img = "/images/Uncut_Crystal_Glasses_Banner.jpg";
if ($category_id == “32”) $img = "/images/Plain_Glasses_Banner.jpg";
if ($category_id == “33”) $img = "/images/Cutlery_Banner.jpg";
if ($category_id == “34”) $img = "/images/Bead_Cutlery_Banner.jpg";
if ($category_id == “35”) $img = "/images/Stainless_Steel_Cutlery_Banner.jpg";
if ($category_id == “36”) $img = "/images/Silverware_Banner.jpg";
if ($category_id == “37”) $img = "/images/Furniture_Banner.jpg";
if ($category_id == “38”) $img = "/images/Table_Linen_Banner.jpg";
if ($category_id == “39”) $img = "/images/Heating_Equipment_Banner.jpg";
if ($category_id == “41”) $img = "/images/Tableware_Banner.jpg";
if ($category_id == “42”) $img = "/images/Glass_Tableware_Banner.jpg";
if ($category_id == “43”) $img = "/images/Stainless_Steel_Tableware_Banner.jpg";
if ($category_id == “44”) $img = "/images/General_Function_Hire_Banner.jpg";
if ($category_id == “50”) $img = "/images/Flooring_Banner.jpg";
if ($category_id == “51”) $img = "/images/Marquees_Banner.jpg";
if ($category_id == “51”) $img = "/images/Stretch_Tents_Banner.jpg";

/* when browsing any other category page */
return "/images/Tableware_Banner.jpg";
}

This is not working - nothing displays on the website..
Can you please tell me where I am going wrong?

The site can be viewed here: http://creativedev2.co.za/SilverSpoon

I am using Joomla 2.5.7 and MetaMod 3.16

CreativeDesigns
Junior Modder
ranks
useravatar
Offline
24 Posts
Administrator has disabled public posting

Re: Virtuemart Categories

Hi CreativeDesigns,

MetaMod is usually used to include complete modules. The "return" statement can only return either module ids or module positions, which MetaMod then includes into the MetaMod's position for you.

That's why returning a path to an image isn't going to work.

However, MetaMod is also able to output HTML code directly. This code will appear "within" the MetaMod as if it was a module.

So in your case, you can use the MetaMod to make in IMG tag that contains that image. You could do it like this:

Code:

$vm = JomGenius("virtuemart"); 

if ( $vm->check("pagetype = category") ) {
    $category_id = $vm->info( "category_id" );

    /* generic image which may be overridden below: */
    $img = "/images/Tableware_Banner.jpg";

    if ($category_id == “27”) $img = "/images/Crockery_Banner.jpg";
    if ($category_id == “28”) $img = "/images/Royal_Porcelain_Crockery_Banner.jpg";
    if ($category_id == “29”) $img = "/images/Continental_Crockery_Banner.jpg";
    if ($category_id == “30”) $img = "/images/Glasses_Banner.jpg";
    if ($category_id == “31”) $img = "/images/Uncut_Crystal_Glasses_Banner.jpg";
    if ($category_id == “32”) $img = "/images/Plain_Glasses_Banner.jpg";
    if ($category_id == “33”) $img = "/images/Cutlery_Banner.jpg";
    if ($category_id == “34”) $img = "/images/Bead_Cutlery_Banner.jpg";
    if ($category_id == “35”) $img = "/images/Stainless_Steel_Cutlery_Banner.jpg";
    if ($category_id == “36”) $img = "/images/Silverware_Banner.jpg";
    if ($category_id == “37”) $img = "/images/Furniture_Banner.jpg";
    if ($category_id == “38”) $img = "/images/Table_Linen_Banner.jpg";
    if ($category_id == “39”) $img = "/images/Heating_Equipment_Banner.jpg";
    if ($category_id == “41”) $img = "/images/Tableware_Banner.jpg";
    if ($category_id == “42”) $img = "/images/Glass_Tableware_Banner.jpg";
    if ($category_id == “43”) $img = "/images/Stainless_Steel_Tableware_Banner.jpg";
    if ($category_id == “44”) $img = "/images/General_Function_Hire_Banner.jpg";
    if ($category_id == “50”) $img = "/images/Flooring_Banner.jpg";
    if ($category_id == “51”) $img = "/images/Marquees_Banner.jpg";
    if ($category_id == “51”) $img = "/images/Stretch_Tents_Banner.jpg";

    echo '<img src="' . $img . '" />';
}

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: Virtuemart Categories

Hi Stephen,

I appreciate your help so much. Thank you.
For some reason, all the images are showing as the Tableware_Banner.jpg when I inspect the item.
So it's not really working correctly sad

CreativeDesigns
Junior Modder
ranks
useravatar
Offline
24 Posts
Administrator has disabled public posting

Re: Virtuemart Categories

Hi Stephen - could you please look into this issue as it is still not working.

CreativeDesigns
Junior Modder
ranks
useravatar
Offline
24 Posts
Administrator has disabled public posting

Re: Virtuemart Categories

I just noticed that the code above has some curly quotes in it, which PHP will object to….. try changing it to the following:

Code:

$vm = JomGenius("virtuemart"); 

if ( $vm->check("pagetype = category") ) {
    $category_id = $vm->info( "category_id" );

    /* generic image which may be overridden below: */
    $img = "/images/Tableware_Banner.jpg";

    if ($category_id == "27") $img = "/images/Crockery_Banner.jpg";
    if ($category_id == "28") $img = "/images/Royal_Porcelain_Crockery_Banner.jpg";
    if ($category_id == "29") $img = "/images/Continental_Crockery_Banner.jpg";
    if ($category_id == "30") $img = "/images/Glasses_Banner.jpg";
    if ($category_id == "31") $img = "/images/Uncut_Crystal_Glasses_Banner.jpg";
    if ($category_id == "32") $img = "/images/Plain_Glasses_Banner.jpg";
    if ($category_id == "33") $img = "/images/Cutlery_Banner.jpg";
    if ($category_id == "34") $img = "/images/Bead_Cutlery_Banner.jpg";
    if ($category_id == "35") $img = "/images/Stainless_Steel_Cutlery_Banner.jpg";
    if ($category_id == "36") $img = "/images/Silverware_Banner.jpg";
    if ($category_id == "37") $img = "/images/Furniture_Banner.jpg";
    if ($category_id == "38") $img = "/images/Table_Linen_Banner.jpg";
    if ($category_id == "39") $img = "/images/Heating_Equipment_Banner.jpg";
    if ($category_id == "41") $img = "/images/Tableware_Banner.jpg";
    if ($category_id == "42") $img = "/images/Glass_Tableware_Banner.jpg";
    if ($category_id == "43") $img = "/images/Stainless_Steel_Tableware_Banner.jpg";
    if ($category_id == "44") $img = "/images/General_Function_Hire_Banner.jpg";
    if ($category_id == "50") $img = "/images/Flooring_Banner.jpg";
    if ($category_id == "51") $img = "/images/Marquees_Banner.jpg";
    if ($category_id == "51") $img = "/images/Stretch_Tents_Banner.jpg";

    echo '<img src="' . $img . '" />';
}

Let me know if that doesn't work.

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: Virtuemart Categories

You're amazing! Thank you!

CreativeDesigns
Junior Modder
ranks
useravatar
Offline
24 Posts
Administrator has disabled public posting

Re: Virtuemart Categories

I take it that worked then - relief!

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4388
Newest User:
wilmer7878
Members Online:
2
Guests Online:
165


Forum Legend:

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