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.

 

Change template depending on given rules

Change template depending on given rules

Hi its me again.

Preamble
My main gripe with joomla is how it assigns modules and templates to the content (via menu ids) It means you need a menu link to every article on your site and assign it to these modules/templates. This becomes massively time consuming when you have a fast updating site.

My Problem
This request is a continuation of my css request. I think I need to change templates depending on the section, or even article id. It would be great to be able to change templates for pages on the site that don't have a menu link. I want to avoid using this completely with metamodpro. I'm hoping some clever javascript or php will be able to overide the default template.

Anyone's advice on this matter would be great!

regards,

Ty

lordbarron
Guest
useravatar
Offline
Administrator has disabled public posting

Re: Change template depending on given rules

Ty,

I can't think of any really good ways to achieve what you are asking for.

The simple fact is that the template for a page has already been loaded by the time any modules are created -- the modules are defined by the template, so the template comes first.

Therefore the only way for a module to swap to a different template is for it to instigate a page redirect to a different URL, a URL that will use that different template.

That might be an approach to try -- setting up new menu items on a hidden menu that are very similar to the menu items on the main menu. But you then assign the 2nd template to each of these hidden menu items. Then you put a MetaMod onto your main menu items, with a rule in it that detects if the page is one that you want to view with your other template. If so, it does a redirect to the other URL.

But this is horrible for lots of reasons - it uses redirects, it would be quite slow, and I can imagine all sorts of messes where you are working out which part of the system a given page should be on. Yech.

I suppose ideally, this sort of decision making process should be at the level of the "Router" - the part of the system that looks at the outgoing URLs that are generated on the system and does any required re-writing (e.g. for SEF URLs), then looks at incoming SEF URLs and decides which  parameters they equate to.

Hmmm.... that opens up some technical possibilities, if it's possible to get into the router for incoming URLs. That way you might be able, technically, to detect certain conditions and dynamically change the Itemid as the requests come in... interesting possibility. But I have no idea if it's really possible or not. It's very advanced Joomla programming.

Sorry I can't be much more help. You're asking for work-arounds for deeply ingrained Joomla behaviour.

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

Re: Change template depending on given rules

I just did some more investigating and found that on any Joomla site, you can specify a URL parameter like this, that overrides the template for that page!

&template=new_template_name_here

This is easier than setting up a duplicate menu structure as I suggested above. So with a bit of PHP magic you could use MetaMod to detect if it was a page that you want in a different template, then rewrite the current URL to include "&template=beez" (or whatever) in it, and do a redirection.

It's still not going to be easy, and it still involves redirections, but it's less bad than I thought :-)  Another nice thing is that the new template is not "sticky" -- i.e. any links from the page you point to won't include the new template parameter, so they'll revert to the normal template.

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

Re: Change template depending on given rules

Oh, this just gets better.

I found that you can make a system plugin that can override the template smile

Stay tuned for a plugin or component/plugin combination that should be able to do what you are asking for.

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

Re: Change template depending on given rules

Sweet, your a legend! I've searched forums high and wide for a solution to this. I've seen lots of news website colour code headers, links etc depending on the site's section so this is something I thought joomla could handle. But the whole attaching parameters for styles, modules etc to links just screws it all up.
I look forward to seeing what you whip up.

Regards,

Ty

lordbarron
Guest
useravatar
Offline
Administrator has disabled public posting

Re: Change template depending on given rules

hmmm, it's going to take a little time... but I'll let you know when there's something available.

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

Re: Change template depending on given rules

Sure thing, good things come to those who wait. Any idea on the license? will it be something similar to metamodpro?

lordbarron
Guest
useravatar
Offline
Administrator has disabled public posting

Re: Change template depending on given rules

I don't know yet! Obviously it won't be exactly like MetaMod because it can't be a module. For ease of use it should be a component that communicates with a plugin, but it's quite a lot of work (meaning more chance I'll charge for it). No promises except that I'm going to work on it some more today.

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

Re: Change template depending on given rules

Thats quite alright, i wont get carried away with ideas on how to use it just yet. I hope its not just me who appreciates the end result of your hard work.

lordbarron
Guest
useravatar
Offline
Administrator has disabled public posting

Re: Change template depending on given rules

I have a Beta version of this now ready - anyone want a copy? Please e-mail me and I'll send you one.

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

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10093
Newest User:
lamanaudio
Members Online:
0
Guests Online:
177

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