Assign Template to CB

13 years 8 months ago #10028 by spikec
Has anyone figured out a hack that will allow assignment of a template to the entire CB component? I understand how joomla is menu driven, and you can only assign a template to a specific menu item...blah blah blah. Right now I can assign my desired template to the parts of CB that have a menu link, but when for example, you click on a members avatar (or any other part of the CB component that you can't tie to a menu item), it goes to the user's profile but reverts to the default template.

It seems to me a simple "if/else" condition in the joomla index.php (around line 195) might do he trick, as in :

if ( $option='com_comprofiler') $template='desired template';
else $cur_template = $mainframe->getTemplate();

I've tried this several different ways, but no workie, probably because my syntax is wrong. Seems to me that this would be an easy way to get around the whole assigning templates mess....
Any thoughts?

Post edited by: spikec, at: 2006/04/11 09:29
13 years 7 months ago #12345 by TheAnt
Please, I need this too.
Help us!!
13 years 6 months ago #13362 by rex339
this looks interesting :)
13 years 6 months ago #13414 by dave
I have had the following script in my index file for a long time - it works great.

In index.php, find the following:
[code:1]// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
echo _TEMPLATE_WARN . $cur_template;[/code:1]

Add Something like the following before the above code:

[code:1]//template hack
if($option == 'com_comprofiler')
{
$cur_template = 'template1';}

elseif($option == 'com_content' && $task == 'blogcategory' && $id == '1' && $Itemid == '131')
{
$cur_template = 'template2';}

[/code:1]

That is it. You can get this to work at the componant level or even down to a specific page. You can have unlimited elsif statements - I have about 12.

Post edited by: dave, at: 2006/05/20 13:00
13 years 6 months ago #13417 by spikec
That is awesome! I read over at joomla.org that assigning a template to a component could not be done. I had been using a workaround of using the desired CB template as the default template, and assigning the real default template to everything else. I appreciate you sharing this!
13 years 4 months ago #17398 by renoa
omg it works!! thank you very much you have no idea how much i suffered from this :laugh:
Moderators: beatnantkrileon
Time to create page: 0.411 seconds

Facebook Twitter LinkedIn