How to change / set the Joomla template programmatically from within a Joomla 1.5+ component

Yup, this might be an interesting feature, but how easy or hard is to implement?

It's simpler, than you might imagine!

Create a function somewhere in your component:

function templatechanger($templatename) {
global $mainframe;
$mainframe->setTemplate = $templatename;
}

Then where you want to call it, initialize the variable, for example like:

$my_templatename="my-template-name";

and call the function:

 templatechanger($my_templatename);

Simple enough?


Benefit from fantastic savings on Free Hosting (http://www.Absolutely-Free-Hosting.com/) , just by taking a look at bigonlinedeal