Tagged: JA MegaStore, Localization, Override, t3 framework
-
AuthorPosts
-
August 25, 2016 at 7:30 am #962925
Hello,
First of all: thank you for providing so many really good templates with the T3 framework. I start to feel comfortable with the framework structure. But I still have a lot to learn. 🙂
Following the localization guide in http://www.t3-framework.org/documentation/extend-com-content#isolate-template I did customizations to JA MegaStore in the
{templatename}/local/
folder and overrides to joomla core files within{templatename}/local/html/
to be template update proof.Everything is fine for general files e.g. in subfolders like
{templatename}/local/html/com_content/
, but I get into trouble with{templatename}/local/html/modules.php
as the contents of this file (copy of the ja_megastore contents of{templatename}/html/modules.php
plus code adjustments) rises a frontend error:Fatal error: Cannot redeclare modChrome_T3Xhtml() (previously declared in (..)/templates/ja_megastore/html/modules.php:34) in (..)/templates/ja_megastore/local/html/modules.php on line 73
The file priorities (loading sequence, the later overrides the earlier one) is ok, but the philosophy apparently causes an error if you define functions within these files.
How can this be resolved without manipulating your template files directly (which does work), thus losing update proofness? [ I need to override your functions to have the menu title multilanguage ready, thus include
$module->title = JText::_($module->title);
in all the functions. – I tried having this as a single line of code in the local variant, but that does not seem to affect the global scope. ]Best regards, Sailor
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
August 26, 2016 at 4:47 am #963162Hi Sailor,
Try to rename this file:
{templatename}/html/modules.php
so the template will use the override file inlocal
folder.But when you update new version template, you will have to rename this file again. This is special file so I’m afraid this is only way to achieve that.
August 26, 2016 at 6:21 am #963186Hi Saguaros,
thanks for the reply. That does work for the moment and enables a fast fix. But it is a pity that the system is not update proof in this case, especially if the maintenance is in the hands of the client.
The resulting error is "fatal", so the page will be definitely broken unless that file is renamed again. – I’d rather loose a title translation than break the site on template update.
Do you see any way to resolve this conflict permanently?
Sincere regards, Sailor
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
August 26, 2016 at 6:52 am #963196Hi Sailor,
I understand your point however, as I mentioned above, this is special file for module rendering, it can’t be inherited like html layout files / CSS or LESS files. So please use our JA Extension Manager component (FREE extension) to update template (or JA products) which can provide you option to make a comparison between current version and updated version, then you will know which files / folders will be updated. We always recommend uses to have this useful step when trying to update new version of our products.
August 26, 2016 at 8:24 am #963221Hi Saguaros,
I respect the recommendation (and like the code check option implented within your JA Extension Manager). However this is not dummy-user-proof as it requires a skilled operator / programmer to review the code changes for desired and/or undesired patches.
The
redeclare
issue for the special filemodules.php
rises because the scripts inhtml
andlocal/html
are loaded in sequence. – Would you instead load this specific file modules.php alternatively?Why?
PATH_TO_JOOMLA/templates/system/html/modules.php
defines the basicmodChrome
functions independent of the template and is usually extended by template specific styles inPATH_TO_JOOMLA/templates/TEMPLATE_NAME/html/modules.php
(https://docs.joomla.org/Applying_custom_module_chrome / http://blog.cre8ive4ever.com/2013/05/modchrome-ausgabe-von-joomla-modulen/).In T3 Framework the contents of the
TEMPLATE_NAME/local/html
folder are meant to override the contents ofTEMPLATE_NAME/html
instead of adding more functions. Thus it is safe to include them alternatively. (Correct me if I am wrong.)My suggestion
In
plugins/system/t3/includes/joomla30/modulehelper.php:207: $chromePath = JPATH_THEMES . '/' . $template . '/html/modules.php';
and
plugins/system/t3/includes/joomla25/modulehelper.php:205: $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php';
change it toinclude_once JPATH_THEMES . '/system/html/modules.php'; if (file_exists(JPATH_THEMES . '/' . $template . '/local/html/modules.php')) { $chromePath = JPATH_THEMES . '/' . $template . '/local/html/modules.php'; } else { $chromePath = JPATH_THEMES . '/' . $template . '/html/modules.php'; }
respectively in
plugins/system/t3/t3.php:355: $chromePath = T3Path::getPath('html/modules.php');
to// We don't need chrome multi times - load either local or template default version if (file_exists(T3Path::getPath('local/html/modules.php'))) { include_once(T3Path::getPath('local/html/modules.php'); } else { $chromePath = T3Path::getPath('html/modules.php'); if (file_exists($chromePath)) { include_once $chromePath; } }
- Make sure to skip
modules.php
when loading the contents of the local folder later.
(Have I missed anything?)
What do you think?
Best regards,
SailorAugust 29, 2016 at 8:35 am #963704Hi Saguaros,
I hope you spent a nice weekend.
We had been talking about getting your T3 templates update proof with respect to isolation of customizations with special regards to
modules.php
.Let’s extend this to
favicon.ico
, which is so far not pulled from thelocal/
folder. In http://www.t3-framework.org/discussions/is-there-really-a-need-for-template-updates-to-overwrite-existing-favicons.html Gardner Luna suggests that it should work like this and a potential failure would be discussed with the dev team (2 years ago), but it does not (yet) work like this by now.
[Edit: T3 Framework 2.6.1]What is your status on that topic?
BR, Sailor
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
August 30, 2016 at 10:09 am #964202Hi Sailor,
I got your point but if you change in file in T3 framework plugin, when you update T3 framework, it will be overridden also <<< you must backup this file >>> so why simply backup modules.php when updating template?
For the favicon, by default, Joomla provides way to override is copy your favicon into template folder. To change the path, you can check the docs here: https://docs.joomla.org/Changing_the_site_favicon
There are only some special files like this, it’s not too difficult for end user to backup before updating though.
September 22, 2016 at 12:01 pm #970195Dear Saguaros,
sorry for the late reply (notification for the update was not received/noticed).
Having a backup of the modules.php is recommended. However if there are multiple administrators or respectively the template setup guy and the customer (to keep it customer-maintained), the backup is easily lost or forgotten. I love the intention of the "local" folder and would like to make use of it as far as possible, that’s why I am bugging you.
With respect to the favicon.ico: I am fully aware of this standard location and procedure. However: A template update / (re)install from JoomlArt will overwrite any customly replaced favicon.icon in this location. – That’s why I am asking for a "local" folder alternative.
Best regards,
Sailor -
AuthorPosts
This topic contains 8 replies, has 2 voices, and was last updated by Saguaros 8 years, 1 month ago.
We moved to new unified forum. Please post all new support queries in our New Forum