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.

 

Confused Template Switching

Confused Template Switching

Hello I am a newbie to metamod. I am trying to setup a demonstration site with template switching. I have purchased metamod pro but I am confused whether I need metamod or Chameleon. I can switch template okay that's not problem it's the repositioning of the modules. For the various templates I have to reposition menus, news, banners, breadcrumbs etc. From the help it looks like I have to create a meta-mod for every position in use that needs switching. For 10 templates that's a lot of modules.

Am I doing this the right way or should I be using Chameleon ? I had a look through the Chameleon docs and it does not mention module positions. It seems Chameleon switches templates but cannot change module positions (not really sure how useful that is)

hence my confusion.

Thanks
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

Hi Paul,

Thanks for your great questions.

Something that neither MetaMod nor Chameleon really address at the moment is the changing module positions that happen when you use different templates. As you have seen, you could do this with MetaMod, but it's a bit "icky". Ideally, I imagine it would be great to have a plugin/system that simply allowed you to say "On this template, rename "X" module position as "Y", and so on for all the templates and positions.

About the best thing I can offer at the moment is the following approach using MetaMod (Pro):

1 - choose some "fake" names for module positions that describe the places on your page where the modules should appear. e.g. "my-top", "my-right", "my-left" etc. These positions should probably not appear in any of the templates.

2 - start with the 1st template, and create a MetaMod for each one of the corresponding position names *in that template*. e.g. on this template, the module position on the left might actually be called "user1", so create a MetaMod in "user1", and simply type "my-left" into the "quick module id or position include" box. Thus, when this template is used the MetaMod will pull all modules from "my-left" and insert them into "user1". Repeat for each of the positions on that template

3 - repeat for each of the templates.


The only real hassle happens if 2 templates have the same module position name, but that module position is in 2 completely different locations in the template. e.g. "user1" might be your "my-left" on one template, and "my-right" on another.

In that case, you just detect the template being used, and pull in the appropriate target position, like this:

- DON'T put anything into the "quick module id and position include" box. Leave it blank.
- use the following PHP code in the PHP box:

$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();
if ($template == "template_1") return "my-left";
if ($template == "template_2") return "my-right";

(note: this is Joomla 1.5 only. Ask if you want a 1.6/7 version)


Once you've done this setup, then just assign modules to my-left, my-right, my-top, my-bottom etc as if they were "real" positions, and the MetaMods will handle assigning them into the right places no matter which template is being used.

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

Re: Confused Template Switching

hello Stephen,

Thank you for the detailed reply. I think I've got it. One more question. Can you confirm if metamod inherits the parameters of the real mod ie it seems to inherit module class suffix, title display but for the real mod pages to display is set in the meta_mod. so for the real mod pages to display = none?

Thanks
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

Sorry, I have been through the documentation and can't find the answer. I am database dev rather than php. How do you specify multiple module

On each line only returns the first ie
return 16;
return 28;

shows module id=16

or

return 16,28; gives error

Is the order of display on the page defined by the order in which they are called ?

Thanks
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

Please ignore found answer wrap in quotes.

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

Hi Paul,

About whether MetaMod inherits "real" parameters such as module class suffix:

If you're using the Pro version, then the modules that MetaMod includes get put into the page just as if MetaMod was not there at all. I.e. if you set module class suffixes etc, then these will apply to the module that you put them in.

If you're not using the Pro version then all the modules that MetaMod includes get put inside the HTML of a basic module - the MetaMod. This means that the included modules end up with 2 lots of HTML around them - their normal module HTML, *plus* the MetaMod's module HTML. In many cases this is fine, but it really depends on the CSS of your page. In some cases the layout will get a bit messed up because you have a module inside a module, and your CSS may not cope with that so well.

Even with the free version, if you set a module class suffix on the "target" modules, this should still appear in the HTML output.

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

Re: Confused Template Switching

Hello Stephen,

I have the pro version and I am nearly there. Last question how do you put params in an if statement. For example.

$changes->mod(42)
->setParam("moduleclass_sfx","-list");
if ( $id == "21" ) return "42";

I have multiple moduleclass_sfx dependent upon the $id ?

thanks
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

Something like this:

$suffix = "";
if ($id == "21") $suffix = "-list";
if ($id == "22") $suffix = "-test1";
if ($id == "23") $suffix = "-test2";
if ($id == "24") $suffix = "-test3";
if ($id == "25") $suffix = "-test4";
if (suffix != "") {
  $changes->mod(42)
    ->setParam("moduleclass_sfx",$suffix);
  return 42;
}


Doing it this way, it's only going to return module 42 if one of the listed ids is found. I assume that's what you want.

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: Confused Template Switching

Hello Stephen,

I am up to 6 templates and a lot of metamods.

//home page login and news
if ( $Itemid == '1' ) return "16,28";

//template menu 42 website page item 32
$suffix = "";
if ($Itemid == "32") $suffix2 = "-list";
if (suffix != "") {
  $changes->mod(42)
    ->setParam("moduleclass_sfx",$suffix);
  return 42;
}

// Gallery 32 on page itemid 34
$suffix2 = "";
if ($Itemid == "34") $suffix2 = "-ms2";
if (suffix2 != "") {
  $changes->mod(32)
    ->setParam("moduleclass_sfx",$suffix2);
  return 32;
}

$suffix3 = "";
if ($Itemid == "40") $suffix3 = "-ms1";
if (suffix3 != "") {
  $changes->mod(32)
    ->setParam("moduleclass_sfx",$suffix3);
  $changes->mod(42)
  ->setParam("moduleclass_sfx",$suffix3);
  return "32,42";
}

I should have mods 32 and 42 but I get mod 42 on page itemid 40 in right position.

debug log

MetaMod debug info:
Module ID: 40
$option: com_content
$view: article
$id: 23
$Itemid: 40
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules: 42

Also returning mod 42 on itemid 34 when it should be mod 32

debug lof

MetaMod debug info:
Module ID: 40
$option: com_content
$view: article
$id: 23
$Itemid: 34
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules: 42

Thank you for the help
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Confused Template Switching

hello Stephen,

I have solved my problems using Case statements. It made more sense for me.

In case others have the same problem here is an example

// meta_right
switch ($Itemid) {
case '1': // home page
return "16,28";
break;

case '32': // website page
  $changes->mod(42)
    ->setParam("moduleclass_sfx","-list");
  return 42;
break;

case '34': // example 2
  $changes->mod(32)
    ->setParam("moduleclass_sfx","-ms2");
  return 32;
break;

case '36': // example 3
  $changes->mod(32)
    ->setParam("moduleclass_sfx","-ms2");
  return 32;
break;

case '40': // eaxmple 5
  $changes->mod(32)
    ->setParam("moduleclass_sfx","-ms1");
  $changes->mod(42)
  ->setParam("moduleclass_sfx","-ms1");
  return "42,32";
break;
}

Regards
Paul

toomanylogins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1680
Total Polls:
6
Total Posts:
5914
Total Posts Today:
1
User Info:
 
Total Users:
10831
Newest User:
bluesky1
Members Online:
0
Guests Online:
176

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