fnagel / generic-gallery

TYPO3 extension: Generic Gallery - One gallery to rule them all!
https://extensions.typo3.org/extension/generic_gallery/
GNU General Public License v3.0
7 stars 12 forks source link

4.3: Template not loaded despite overridden template path #45

Closed cweiske closed 7 months ago

cweiske commented 2 years ago

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 commented 8 months ago

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: https://github.com/fnagel/generic-gallery/pull/56

cweiske commented 8 months ago

Configuring the whole file path is better indeed.

fnagel commented 7 months ago

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