Assign Template to CB

14 years 3 months ago #10028 by spikec
Assign Template to CB was created 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

Please Log in to join the conversation.

14 years 2 months ago #12345 by TheAnt
Replied by TheAnt on topic Re:Assign Template to CB
Please, I need this too.
Help us!!

Please Log in to join the conversation.

14 years 2 months ago #13362 by rex339
Replied by rex339 on topic Re:Assign Template to CB
this looks interesting :)

Please Log in to join the conversation.

14 years 2 months ago #13414 by dave
Replied by dave on topic Re:Assign Template to CB
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

Please Log in to join the conversation.

14 years 2 months ago #13417 by spikec
Replied by spikec on topic Re:Assign Template to CB
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!

Please Log in to join the conversation.

14 years 2 weeks ago #17398 by renoa
Replied by renoa on topic Re:Assign Template to CB
omg it works!! thank you very much you have no idea how much i suffered from this :laugh:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.447 seconds

Facebook Twitter LinkedIn