Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » Chameleon / ChameleonLite
- » ChameleonLite
- » How to assign a template to a...
How to assign a template to a section/category - not just menu items?
Re: How to assign a template to a section/category - not just menu items?
Using the new MetaTemplate v1.5:
Check the section id:
if ( $content_genius->check("section_id = 5") ) return true;
Check the category id:
if ( $content_genius->check("category_id = 15") ) return true;
One of these rules (with ID numbers edited for your site) would go into the PHP box in the rule. If you have several categories/sections that are to use the same template, then you can put in several ID numbers into the same genius call, e.g.
if ( $content_genius->check("category_id = 15,16,17") ) return true;
JomGenius is all completely brand new, so if you need any help with it (or if I got the recipes wrong...) please write back.
If PHP looks like Chinese to you, then MetaTemplate Pro has a graphical selector where you can select the particular sections or categories you want to trigger a certain template. Up to you.
Cheers,
Stephen
Re: How to assign a template to a section/category - not just menu items?
hi
I use K2, how do I assign a template to a category and items
for example..
index.php?option=com_k2&view=itemlist&task=category&id=40:servicios-en-linea&Itemid=12
and others internal items
Thanks
Re: How to assign a template to a section/category - not just menu items?
Many thanks for your help metamodguy
I have the following in the PHP block:
if ( $content_genius->check("section_id = 5") ) return true;
if ( $content_genius->check("category_id = 6") ) return true;
Then under SUCCEED Actions I set the template I want to use
Published and saved. However the default template is still used, not the template i chose under SUCEED Actions
Any help is greatly appreciated
Kind regards
Matthew
Re: How to assign a template to a section/category - not just menu items?
Hi Matthew,
sorry, I just found a bug in MetaTemplate 1.5. I just released 1.5b with the bug fixed. Can you please download it again and reinstall it? Over the top of the old one is fine.
It might pay to delete the rule you have and start again with a new rule. Hopefully it will work this time!
Best regards,
Stephen
[edited: I originally wrote 1.4 when I meant 1.5]
27-Jul-10 10:52:48
Re: How to assign a template to a section/category - not just menu items?
Re: How to assign a template to a section/category - not just menu items?
Hi i've updated to 1.5c but it's still not working. Here's what i'm doing:
I'm using the following under "Advanced"
if ( $content_genius->check("section_id = 5") ) return true;
if ( $content_genius->check("category_id = 6") ) return true;
Then under "SUCCEED Actions" i've set the template I want to be used but still the article pops up with the default template.
Funnily enough even though i've installed 1.5c it still says "MetaTemplate Component 1.5b (26 July 2010)". I've even tried deleting metatemplate (not just installing over previous version) but still says MetaTemplate Component 1.5b (26 July 2010).
Could it be that i'm opening the articles in a rokbox? Although if I change the default template it opens the articles with that template in the rokbox.
Your efforts are greatly appreciated!
Kind regards
Matt
Re: How to assign a template to a section/category - not just menu items?
Hi Matt,
ooops about the version number - that hadn't got updated for some reason. The rest of the file *had* been updated though. I've just replaced the 1.5c on the site with a copy that actually has the right version number inside it.
I'm not sure if the rokbox has anything to do with it - but it might have. If it's obeying the default template then I would have thought it would work.
Could you try something else: in the PHP box, try the following code. This might temporarily seriously mess up your pages, but it will also print some debugging info at the very top of the page (you might need to go to page source to see it):
echo "I THINK THE SECTION ID IS: " . $content_genius->info("section_id") . " AND THE CATEGORY ID IS: " . $content_genius->info("category_id") . "<br><br>\n\n";
If you're lucky, you'll see that at the top of every page. It can upset some components because the output comes before any page headers... but at least it will give an idea of what MetaTemplate thinks the category id and section id are.
If it's still not working then I'd be more than happy to log into your site and debug it directly...
Best regards,
Stephen
EDITED: one of the "info()" things was wrongly stated as "check()" which was wrong.
28-Jul-10 21:16:32
Re: How to assign a template to a section/category - not just menu items?
Hi Matt,
The first thing I noticed was that I had made a mistake in the last bit of code I sent - so the reason it never gave the right content_id was because I gave you the wrong code. Now that that's correct, it's giving out the right information.
However, that brings me to the next point. How exactly do you want the template applied to the article displayed in the rokbox? The full template you want to apply to it has all kinds of images etc in it, and they're not going to look good in a rokbox. It's kind of good that it's just a plain background.
In any case it appears that the module you are using, DM Article Titles List PRO, is adding its own parameter to the URL ("tmpl=component") and although MetaTemplate is trying to assign the template that you wanted, it's being overridden by this other blank template. I just read some more about that at http://www.howtojoomla.net/2008072288/h … -joomla-15
So the question again - do you really want the "soa" template applied to the article when it's inside the rokbox? If so, you'll need to get rid of that extra URL parameter being added. I think it's probably hard coded into the dmarticletitleslistpro module.
Even if the article is displayed outside of the rokbox, the fact that it has the same Itemid as the main SOA article, and you have assigned the soa template to the SOA menu item, means that the sub-article is inheriting that template (as long as it doesn't have that "tmpl=component" parameter). So MetaTemplate really isn't needed here at all.
Lastly, I just wanted to check on something. The rule you are using is:
if ( $content_genius->check("section_id = 5") ) return true;
if ( $content_genius->check("category_id = 6") ) return true;
What this does is checks if the section is 5. If so, it will use the new template. Then it checks if the category is 6, and again uses the new template. So the new template will be used for everything in section 5, and everything in category 6. Is this what you wanted? It's an "OR" not an "AND".
If you wanted to include everything that is only in both, then you would need to put:
if ( $content_genius->check("section_id = 5") and $content_genius->check("category_id = 6") ) return true;
Hope that helps,
Stephen
Re: How to assign a template to a section/category - not just menu items?
When the article pops up in the rokbox, I would like it to apply the SOA template CSS - so the heading 2 is pink, the text is black, and the background is a pale yellow.
DM Article Titles List Pro has a setting 'HTML' - where it opens up an entire page in rokbox including all images etc on that template, or 'RAW' where it just opens the article itself - I have it on RAW as I want just the article popping up, however I want the SOA template CSS applied, not the default blue template CSS.
I believe this problem is probably caused by DM Article Titles Pro so I have emailed the author of the module. Many thanks with all your help so far Stephen I will update you on my findings!
- Index
- » Chameleon / ChameleonLite
- » ChameleonLite
- » How to assign a template to a...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8025
- Newest User:
- chavez1304
- Members Online:
- 2
- Guests Online:
- 138
- Online:
- chavez1304, dianegreen9
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked