Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.3: Template not loaded despite overridden template path #45

Closed
cweiske opened this issue Jul 22, 2022 · 3 comments · Fixed by #56
Closed

4.3: Template not loaded despite overridden template path #45

cweiske opened this issue Jul 22, 2022 · 3 comments · Fixed by #56

Comments

@cweiske
Copy link
Contributor

cweiske commented Jul 22, 2022

I tried to use the gallery extension as base for my own gallery, only wanting to adjust the template file by overriding it in my provider extension.

So I installed generic_gallery 4.3.0, included the default typoscript template and set the constant to override the template directory:

plugin.tx_genericgallery.view.templateRootPath = EXT:myext/Resources/Private/Templates/

Then I created myext/Resources/Private/Templates/GalleryCollection/Show.html and .. it did not get loaded.
(IMO this is the standard way of overriding templates in nearly all typo3 extensions).

To debug the issue, I removed generic_gallery's Show.html and now got an exception:

(1/1) #1257246929 TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException

Tried resolving a template file for controller action "GalleryCollection->show" in format ".html",
but none of the paths contained the expected template file
(/var/www/typo3/public/typo3conf/ext/generic_gallery/Resources/Private/Templates/GalleryCollection/Show.html).

The following paths were checked:
/var/www/typo3/public/typo3conf/ext/generic_gallery/Resources/Private/Templates/,
/var/www/typo3/public/typo3conf/ext/myext/Resources/Private/Templates/

I confirmed multiple times that /var/www/typo3/public/typo3conf/ext/myext/Resources/Private/Templates/GalleryCollection/Show.html actually exists, which it did.


In the end I found that generic_gallery/Configuration/TypoScript/setup.typoscript includes EXT:generic_gallery/Configuration/TypoScript/Examples/setup.typoscript, which sets

plugin.tx_genericgallery.settings.gallery.default.template = EXT:generic_gallery/Resources/Private/Templates/GalleryCollection/Show.html

.. which overrides the template path configured earlier.


This is very confusing.

I suggest not loading the example typoscript with the standard generic_gallery typoscript (instead adding an example typoscript record that can be selected in the typoscript template setup), and adding a section about templating in the manual.

@fnagel
Copy link
Owner

fnagel commented Jan 19, 2024

Thanks for the feedback and a big sorry for the (very!) delayed response.

You are right, the current templating mechanism might be a little confusing when starting with this extension. The non standard behavior is a left over of the pre Extbase / Fluid era of this extension and the fact it's needed to somehow configure the template file per gallery type.

Extbase / Fluid only allows to configure one template path which is added to the controller and action name in order to determine the full file path to the template. For this extension we have another aspect: it allows to have different gallery types with (obviously) different templates. So controller and action for determining the last folder and file name is not sufficient.

I think configuring the whole file path (template = EXT:my_ext/Resources/Private/Templates/SomeFolder/SomeFile.html) is more convenient than using a variable like templateName = SomeFile or something similar. What do you think?

I do see that the docs need an update to better reflect on this behavior. Probably the default gallery type should have no template and templateItem TS settings set, so one can override the template as you tried to do.

I've added a PR with some proposed changes and would love to hear your feedback! Please see here: #56

@cweiske
Copy link
Contributor Author

cweiske commented Jan 21, 2024

Configuring the whole file path is better indeed.

@fnagel
Copy link
Owner

fnagel commented Jan 25, 2024

Thanks for the feedback! PR has been merged :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants