-
AuthorPosts
-
doorknob Friend
doorknob
- Join date:
- December 2013
- Posts:
- 36
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 20 times in 1 posts
January 24, 2014 at 11:57 pm #194060After digging a bit deeper into the issue of errors caused by the T3::getTemplate() function, it seems to me that the issues are:
1 T3::getTemplate() needs to be compatible with both the frontend and backend. This is because some frontend programs are run in the backend to support the ThemeMagic feature. Any program that needs the current template details and is also run by ThemeMagic must use this function. I have several custom block programs that use this function. It is not possible to differentiate between normal frontend running and ThemeMagic using isadmin() because that function returns a values of false in the frontend and also when run by ThemeMagic in the backend.
2 In the backend, the style id is passed between screens as the parameter ‘id’ but in the frontend, this parameter is passed as ‘styleid’. The T3::getTemplate() function deals with this by getting the value of styleid but if that is not present, getting id instead. That supports the backend processes ok but causes a problem in the frontend because styleid is usually not populated and if id happens to be populated, it will not be a template id, leading to randomly selecting the wrong theme by accident.I have made a modification that allows all backend functionality to work as normal without the need to load the id parameter in frontend processes. It does this by replicating the id value as styleid in each of the backend processes, avoiding the need for getTemplate() to load any id value.
t3/includes/core/t3.php line 335 (v 2.1.0) is changed from
$id = $input->getInt('styleid', $input->getInt('id'));
to$id = $input->getInt('styleid');
so that the id value is no longer readt3/includes/core/admin.php lines 190 to 209 (v 2.1.0) are changed from:
$jdoc->addScriptDeclaration ( '
T3Admin = window.T3Admin || {};
T3Admin.adminurl = '' . JUri::getInstance()->toString() . '';
T3Admin.t3adminurl = '' . T3_ADMIN_URL . '';
T3Admin.baseurl = '' . JURI::base(true) . '';
T3Admin.rooturl = '' . JURI::root() . '';
T3Admin.template = '' . T3_TEMPLATE . '';
T3Admin.templateid = '' . JFactory::getApplication()->input->get('id') . '';
T3Admin.langs = ' . json_encode($langs) . ';
T3Admin.devmode = ' . $params->get('devmode', 0) . ';
T3Admin.themermode = ' . $params->get('themermode', 1) . ';
T3Admin.eids = [' . implode($eids, ',') .'];
T3Admin.telement = '' . T3_TEMPLATE . '';
T3Admin.felement = '' . T3_ADMIN . '';
T3Admin.themerUrl = '' . JUri::getInstance()->toString() . '&t3action=theme&t3task=thememagic' . '';
T3Admin.megamenuUrl = '' . JUri::getInstance()->toString() . '&t3action=megamenu&t3task=megamenu' . '';
T3Admin.t3updateurl = '' . JURI::base() . 'index.php?option=com_installer&view=update&task=update.ajax' . '';
T3Admin.t3layouturl = '' . JURI::base() . 'index.php?t3action=layout' . '';
T3Admin.jupdateUrl = '' . JURI::base() . 'index.php?option=com_installer&view=update' . '';'
);
to// Ensure that the admin URL contains a single occurrence of styleid
$templateid = JFactory::getApplication()->input->get('id');
$admin_url = JUri::getInstance()->toString();
if (strpos($admin_url, '&styleid=') === false) {
$admin_url .= '&styleid=' . $templateid;
}
$jdoc->addScriptDeclaration ( '
T3Admin = window.T3Admin || {};
T3Admin.adminurl = '' . $admin_url . '';
T3Admin.t3adminurl = '' . T3_ADMIN_URL . '';
T3Admin.baseurl = '' . JURI::base(true) . '';
T3Admin.rooturl = '' . JURI::root() . '';
T3Admin.template = '' . T3_TEMPLATE . '';
T3Admin.templateid = '' . $templateid . '';
T3Admin.langs = ' . json_encode($langs) . ';
T3Admin.devmode = ' . $params->get('devmode', 0) . ';
T3Admin.themermode = ' . $params->get('themermode', 1) . ';
T3Admin.eids = [' . implode($eids, ',') .'];
T3Admin.telement = '' . T3_TEMPLATE . '';
T3Admin.felement = '' . T3_ADMIN . '';
T3Admin.themerUrl = '' . $admin_url . '&t3action=theme&t3task=thememagic' . '';
T3Admin.megamenuUrl = '' . $admin_url . '&t3action=megamenu&t3task=megamenu' . '';
T3Admin.t3updateurl = '' . JURI::base() . 'index.php?option=com_installer&view=update&task=update.ajax' . '';
T3Admin.t3layouturl = '' . JURI::base() . 'index.php?t3action=layout' . '';
T3Admin.jupdateUrl = '' . JURI::base() . 'index.php?option=com_installer&view=update' . '';'
);
Phil
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
January 25, 2014 at 7:14 am #519782Hi Phil,
Please provide a test case which causes the error on this function. We will check and improve it. Actually, we do not want the scenario that the T3 loads and runs every Joomla run.
doorknob Frienddoorknob
- Join date:
- December 2013
- Posts:
- 36
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 20 times in 1 posts
January 25, 2014 at 9:10 am #519791<blockquote>Actually, we do not want the scenario that the T3 loads and runs every Joomla run.</blockquote>I’m not clear what you mean by this. T3 runs the template. It must load on every run
doorknob Frienddoorknob
- Join date:
- December 2013
- Posts:
- 36
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 20 times in 1 posts
January 26, 2014 at 8:22 am #519848I set up a new test site with J3.2.1, T3 and T3_Bs3_Blank and then installed iCagenda (an event management component which uses a parameter called ‘id’ to identify events). After integrating my custom layout block program that calls the T3 function, I was able to demonstrate that the function causes an error. I had originally used the T3 function in this frontend code because I found that the standard Joomla function for getting the current template caused the style edit screen to crash when editing the layout tab but I decided to try removing the T3 function completely and test whether the backend function could operate without it and found that it now seems to work fine in v2.1.0.
All this comes down to now that I have removed it completely from all programs that run in the frontend, all is working as I expected and I apologise for wasting your time.
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
January 27, 2014 at 2:39 am #519910Hi Phil,
Thanks for taking a deep look into our framework. We welcome any suggestion and will check if we can apply those inputs to improve the framework.
-
AuthorPosts
This topic contains 5 replies, has 2 voices, and was last updated by Wall Crasher 10 years, 10 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum