I have the following code:

defined( '_JEXEC' ) or die;

class plgSystemTemplateSwitcher extends JPlugin
        function onAfterInitialise()
                $input = JFactory::getApplication()->input;
                $session = JFactory::getSession();
                $template = $input->getCmd( 'template', '' );
                if ( $template !== '' ) {
                $session->set( 'templateChanged', $template );
                if ( $session->get( 'templateChanged', '' )!== '' ) {
                $input->set( 'template', $session->get( 'templateChanged', '' ) );

This code is used as plugin to change the template for the current user. They click a link which contains the GET parameter template=mytemplate and the template is saved into user session and gets displayed.

I changed:

$template = $input->getCmd( 'template', '' );


$template = JRequest::getVar('template');

But I have a Joomla 1.5 site which doesn't support the following:

$input = JFactory::getApplication()->input; 

I got an error when try to set $input->set().

Anyone can help me to port this code to 1.5 version?

1 Answer 1


To set something on Joomla 1.5, you will need to use setVar, like so:

$template = JRequest::getVar('template');
JRequest::setVar('template', $template); 


Joomla 1.5 is extremely old and is not officially supported anymore. You will also find people on here less willing to support you. Please consider migrating your website to the latest version of Joomla, mainly for security reasons.

  • Thanks, no errors...but plugin not propertly working :( I know that joomla upgrading is very difficult..
    – Dimm
    Commented Jan 24, 2015 at 18:14
  • Unfortunately I do not have Joomla 1.5, nor do I wish to put it on my localhost. The best thing you can do is read through the Joomla documentation and other tutorials online. This is the issue with older versions of Joomla, people have to go to greater end to help
    – Lodder
    Commented Jan 24, 2015 at 18:26
  • Ah, cookies cache problem: I clear cookies (two times!) and now this code works properly. I will try to update to newest version also. Thanks a lot!
    – Dimm
    Commented Jan 25, 2015 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.