User tests: Successful: Unsuccessful:
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>');
}
The component should render its output into the template you used for <alternative_template>.
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>.
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.
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.
Labels |
Added:
?
|
Rel_Number | ⇒ | 6096 | |
Relation Type | ⇒ | Pull Request for |
@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.
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?
The GitHub repo for the component.
Category | ⇒ | Libraries |
Easy | No | ⇒ | Yes |
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/)
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".
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-02-17 17:52:01 |
Milestone |
Added: |
I don't know how to use GIT yet. How can I download the updated code to test on my site?