? Success
Pull Request for # 6096

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
16 Feb 2015

Steps to reproduce the issue

In a Joomla 3.3 site, add the following constructor to the top of a component and change to another template you have available that isn't the site default.

function __construct() {
    parent::__construct();        
    $app = JFactory::getApplication();
    $app->setTemplate('<alternative_template>');
}

Expected result

The component should render its output into the template you used for <alternative_template>.

Actual result

Under 3.3 the component will still render its output into the default site template. Under 2.5 it will use whatever template you used for <alternative_template>.

System information (as much as possible)

My website was migrated from 2.5.28 to 3.3 using the automatic migration option, and then all the DS constants in my custom component were replaced with '/' and the appropriate class names updated to include Legacy. The site uses custom templates throughout that were developed by me. It is hosted on a Rackspace managed cloud server behind a load-balancer. The web server runs under Ubuntu LTS 14.4, using Apache 2.4.7, PHP 5.5.9 and MySQL 5.6.19.

Additional comments

Note: I migrated from 2.5 to 3.3 so can't say if earlier subversions of 3 had the problem I describe .

JApplicationSite::setTemplate() stores the template name you give it into the JApplicationCms::template property, but in Joomla 3.3 the render method in the same class uses the getter to retrieve a property called theme, which the getter JApplicationWeb gets from its config property that is a registry object.

So between 2.5 and 3.3 I see there has been a change in the terminology used for template and a change in the way this information is stored and retrieved that hasn't been applied to JApplicationSite::setTemplate().

If I replace JFactory::getApplication('')->setTemplate() on my component with JFactory::getApplication()->set('theme', '') it works, so this is my workaround.

avatar mbabker mbabker - open - 16 Feb 2015
avatar joomla-cms-bot joomla-cms-bot - change - 16 Feb 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 16 Feb 2015
The description was changed
Rel_Number 6096
Relation Type Pull Request for
avatar nickweavers
nickweavers - comment - 16 Feb 2015

I don't know how to use GIT yet. How can I download the updated code to test on my site?

avatar Bakual
Bakual - comment - 16 Feb 2015

@nickweavers Try with the patchtester (https://github.com/joomla-extensions/patchtester).
It's a Joomla component you can install and which lets you apply patchs directly from GitHub to your Joomla installation. You can also revert them afterwards.

avatar nickweavers
nickweavers - comment - 16 Feb 2015

Okay, took the changes and manually applied. They fix the problem for me. Thanks @mbabker.

Also, thanks @Bakual, just saw your comment pop up as I was writing this and will try the patchtester. Sounds very useful.

avatar nickweavers
nickweavers - comment - 16 Feb 2015

Just encountered a practical problem with patchtester in that there may be other changes in the patched file that require other files to be patched too. This system is really useful for a level of Joomla code that is pretty much in synch with the development version in github, but less so for trying patches on installs that are comparatively behind. So in my case, making only the updates directly related to the issue I raised worked, but when I tried the patchtester I got a version of the file that had numerous other updates that were dependent on changes outside of just that file (like the new method checkUserRequireReset() that must be in the parent class or another upstream derivative, and JRegistry becoming Registry which must be related to other external changes.

Is there a preferred place to discuss patchtester?

avatar mbabker
mbabker - comment - 16 Feb 2015

The GitHub repo for the component.

avatar zero-24 zero-24 - change - 16 Feb 2015
Category Libraries
avatar zero-24 zero-24 - change - 16 Feb 2015
The description was changed
Easy No Yes
avatar zero-24 zero-24 - alter_testresult - 16 Feb 2015 - nickweavers: Tested successfully
avatar Bakual
Bakual - comment - 16 Feb 2015

The patchtester of course isn't meant to be used on productive sites. It's meant to be used on a testing site where you have an up-to-date version of Joomla. Like the current beta-3 or a nightly build (http://developer.joomla.org/cms-packages/)

avatar infograf768
infograf768 - comment - 17 Feb 2015

Tests:
If I use beez3 as default: I get for this contact page:

normal-load

Switching to protostar as default, I patched and added the code in com_contact controller to load beez3 instead of protostar.
Result:

set_template-load

Something went wrong it seems.

avatar mbabker
mbabker - comment - 17 Feb 2015

Nope, it's working right. When you call setTemplate without any params, then there are no template params to use and an empty Registry is stored. In the case of calling setTemplate('beez3'), you end up using the template without any defined params and in the template there are no default values in any of the params variables. So, as broken as it may look, it is "correct".

avatar wilsonge
wilsonge - comment - 17 Feb 2015

OK based on that I'm merging this as counting JM as a successful test based on @mbabker 's comment

avatar wilsonge wilsonge - change - 17 Feb 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-02-17 17:52:01
avatar wilsonge wilsonge - close - 17 Feb 2015
avatar wilsonge wilsonge - reference | - 17 Feb 15
avatar wilsonge wilsonge - merge - 17 Feb 2015
avatar wilsonge wilsonge - close - 17 Feb 2015
avatar wilsonge wilsonge - change - 17 Feb 2015
Milestone Added:
avatar mbabker mbabker - head_ref_deleted - 18 Feb 2015

Add a Comment

Login with GitHub to post a comment