Set Templates for each component

231 views
Skip to first unread message

gopi gopi

unread,
Nov 7, 2011, 11:49:56 PM11/7/11
to joomla-de...@googlegroups.com
In Joomla1.7,we can set the different templates for a number of component.

Like i am using 3 component ....

I set a  Atomic - Default template for 'AAA - Component'

then i set a Beez5 - Default-Fruit Shop template for 'BBB - Component'.

then Beez2 - Parks Site template for 'CCC - component'.

We can set  different template by using menu manager only but i am intermediate my component to other component internally.

I have set a template for 'AAA - component'(  Atomic - Default )  while i am intermediate the component of 'BBB - component' it's changed into default template(Beez2 - Default).

Any solution for this ???



--
Regards

Gopi.A

Mark Dexter

unread,
Nov 8, 2011, 11:24:00 AM11/8/11
to joomla-de...@googlegroups.com
I believe you could do this pretty easily in a plugin.  You would need to have a place to enter the mapping information the maps each component to a specific template. Then I believe you could just override the assigned template in the plugin code. I'm not sure off the top of my head exactly where you would do this, but it should be reasonably straightforward.

Good luck. Mark




--
Regards

Gopi.A

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Hannes Papenberg

unread,
Nov 8, 2011, 11:40:06 AM11/8/11
to joomla-de...@googlegroups.com
I don't understand you fully, but I'm guessing that you are missing the
ItemID at some point in your URLs. Without that ItemID, Joomla does not
know which template to use and uses the default template for the site.

Hannes

Am 08.11.2011 05:49, schrieb gopi gopi:
> In Joomla1.7,we can set the different templates for a number
> of component.
>
> Like i am using 3 component ....
>
> I set a Atomic - Default

> <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?option=com_templates&task=style.edit&id=3> template


> for 'AAA - Component'
>
> then i set a Beez5 - Default-Fruit Shop

> <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?option=com_templates&task=style.edit&id=6> template


> for 'BBB - Component'.
>
> then Beez2 - Parks Site

> <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?option=com_templates&task=style.edit&id=114> template


> for 'CCC - component'.
>
> We can set different template by using menu manager only but i am
> intermediate my component to other component internally.
>
> I have set a template for 'AAA - component'( Atomic - Default

> <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?option=com_templates&task=style.edit&id=3> ) while


> i am intermediate the component of 'BBB - component' it's changed into
> default template(Beez2 - Default

> <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?option=com_templates&task=style.edit&id=4>).


>
> Any solution for this ???
>
>
>
> --
> Regards
>
> Gopi.A
>

gopijack

unread,
Nov 15, 2011, 1:23:53 AM11/15/11
to Joomla! General Development
Hi,

I got solution but this only temporary solutions.

because,every templates are loading from includes/application.php in
getTemplate($params = false).

Using this function only every templates loading,In this function it
will get each every current page template id and template name.
If we use setTemplate() function it won't work any more,because in
getTemplate($params = false) function template id and template name.
load directly from the database so it will set as per the database
requirements.

so,i thought to hack this getTemplate($params = false).
i added one function like this

function fetch_template($extn){ //$extn contains name of the
component (3rd party extension component)

if($extn!=""){
$db = &JFactory::getDBO();
$select = "select * from #__menu where menutype='mainmenu'";
$db->setQuery($select); $result = $db->loadObjectlist();
foreach($result as $result){
if (preg_match("/\b$extn\b/i", "$result->link")) {
if($result->template_style_id!=0){
$select = "select * from #__menu where menutype='main'";
$db->setQuery($select); $result_ideal = $db-
>loadObjectlist();
foreach($result_ideal as $result_ideal){
$id = $result_ideal->id;
}
}
}
}
}
}return $result_ideal->id;

}


In getTemplate():

I add $com = JRequest::getVar('option');
if($com == "com_abcde"){
$post= JRequest::get('post');
$extn = $post['extn']; //extn is a variable i passes in post.

$id = $this->fetch_template($extn);//$extn you have post the 3rd
party extension and also change the template ID

//using this $id,you can fetch the template name from the
templat_style table

if (isset($templates[$id])) {
$template = $templates[$id];
}
else {
$template = $templates[0];
}

// Allows for overriding the active template from the request
$template->template = JRequest::getCmd('template', $template-
>template);
$template->template = JFilterInput::getInstance()->clean($template-
>template, 'cmd'); // need to filter the default value as well

// Fallback template
if (!file_exists(JPATH_THEMES . '/' . $template->template . '/
index.php')) {
JError::raiseWarning(0, JText::_('JERROR_ALERTNOTEMPLATE'));
$template->template = 'beez_20';
if (!file_exists(JPATH_THEMES . '/beez_20/index.php')) {
$template->template = '';
}
}
}

that's it !

I got it form above hack,now i can set each template for a each
component (Not only the main menu).

On Nov 8, 9:40 pm, Hannes Papenberg <hackwa...@googlemail.com> wrote:
> I don't understand you fully, but I'm guessing that you are missing the
> ItemID at some point in your URLs. Without that ItemID, Joomla does not
> know whichtemplateto use and uses the defaulttemplatefor the site.
>
> Hannes
>
> Am 08.11.2011 05:49, schrieb gopi gopi:
>
>
>
>
>
>
>
> > In Joomla1.7,we cansetthe different templates for a number
> > ofcomponent.
>
> > Like i am using 3component....
>
> > Iseta Atomic - Default
> > <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?opti...>template
> > for 'AAA -Component'
>
> > then iseta Beez5 - Default-Fruit Shop
> > <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?opti...>template
> > for 'BBB -Component'.
>
> > then Beez2 - Parks Site
> > <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?opti...>template
> > for 'CCC -component'.
>
> > We canset differenttemplateby using menu manager only but i am
> > intermediate mycomponentto othercomponentinternally.
>
> > I havesetatemplatefor 'AAA -component'(  Atomic - Default
> > <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?opti...> )  while
> > i am intermediate thecomponentof 'BBB -component' it's changed into
> > defaulttemplate(Beez2 - Default
> > <http://adodis.in/gopi/ccidealplatform210/administrator/index.php?opti...>).
Reply all
Reply to author
Forward
0 new messages