No Code Attached Yet
avatar thalueng
thalueng
6 May 2020

Steps to reproduce the issue

// access from administrator component
$app = CMSApplication::getInstance('site'); // Joomla\CMS\Application\SiteApplication
$template = $app->getTemplate(true); // throws exception

Expected result

return site template

Actual result

throws exception

System information (as much as possible)

J3.9.18

Additional comments

finds the template, but throws exception when verifying the template really exists.
"file_exist" in SiteApplication.php (line 544/561) should check against JPATH_SITE.'/templates' instead of JPATH_THEMES.

work around: create (empty) index.php in folder /administrator/templates/my-site-template-name/

avatar thalueng thalueng - open - 6 May 2020
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 May 2020
avatar ReLater
ReLater - comment - 6 May 2020

access from administrator component

return site template

How should the backend know which params of several possible site templates/styles you want?

avatar thalueng
thalueng - comment - 6 May 2020

Well, the active template. The code finds everything correctly, just replace JPATH_THEMES as I suggested.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28956.

avatar ReLater
ReLater - comment - 6 May 2020

Well, the active template.

If you have several templates and/or styles: What is the active template when you are in the back-end?
It depends on the active page (menu item) in the front-end which template or style is active.

That's what I don't understand.

avatar thalueng
thalueng - comment - 6 May 2020

Maybe I should add that the 2 lines of code I posted finds the active site template without any issues, when called from the front-end, since JPATH_THEMES points to /templates. But when called from the back-end, JPATH_THEMES points to /administrator/templates. As it's an instance of SiteApplication, everythings works for the back-end as well (it finds the template in the db), up to the point when the code checks whether the template found does exist on the file system. It's there were it should check against /templates/, but it does check against JPATH_THEMES which points to /administrator/templates/.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28956.

avatar ReLater
ReLater - comment - 6 May 2020

Well, the active template. The code finds everything correctly, just replace JPATH_THEMES as I suggested.

Provide a pr if you think so: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

avatar brianteeman
brianteeman - comment - 6 May 2020

Maybe I should add that the 2 lines of code I posted finds the active site template without any issues,

But not the active style which is the important thing? A template can have many styles and the params are for the style not for the template

avatar ReLater
ReLater - comment - 6 May 2020

Maybe I should add that the 2 lines of code I posted finds the active site template without any issues, when called from the front-end,

I think you mean the template marked as "Standard". But these params can be completely irrelevant. There are cases where the Standard template is never used in the front-end.

avatar thalueng
thalueng - comment - 6 May 2020

True, but in my case I just use one template in the front-end. If I read the code correctly then getTemplate tries to identify the menu item and the template active for that menu item. If it can't figure it out, then the template active for the home item is selected and returned. Called from front-end ok, called from back-end throw exception with conclusion that the template does not exist in the file system. Certainly not what I would expect.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28956.

avatar joomdonation joomdonation - change - 12 Nov 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-11-12 10:36:44
Closed_By joomdonation
Labels Added: No Code Attached Yet
Removed: ?
avatar joomdonation joomdonation - close - 12 Nov 2022
avatar joomdonation
joomdonation - comment - 12 Nov 2022

The problem here is that we use JPATH_THEMES to check for existence of the template. Unfortunately, JPATH_THEMES is coupled with the active application, mean administrator app in this case, result in the template does not exist error

We also could not changed the code to JPATH_SITE.'/templates' as you suggested because Joomla allows custom defined constants.

So while the issue is valid, I'm afraid of it will be a won't fix issue for the time being. Please use the workaround you found or any working custom code (I also write custom code myself to detect the template).

Add a Comment

Login with GitHub to post a comment