?
avatar thednp
thednp
4 Aug 2020

Problem identified

Initially I've posted a question on joomla.stackexchange.com, but I think it would be better to report the issue right here.
It seems addfieldprefix isn't working with Joomla 4 SITE templates, also there is no documentation, resource or any information on using namespaces with Joomla 4 templates.
So far, namespaced plugins seem to work fine when re-using custom form fields from plugin to plugin, but a template cannot do that with it's own custom fields or namespaced plugin form fields.
Even if we were to implement something like a library, we would still not be able to use them with templates.

Proposed solution

Probably editing Joomla/libraries/namespacemap.php to include template and enable the ability to add <namespace>Joomla\CMS\Template\TemplateName</namespace> in the templateDetails.xml file.

Open questions

  • Is this something that's not implemented yet, or is there a plan to implement namespace and a usable replacement for addfieldpath with addfieldprefix to work with templates? We can use the namespace to extend a template namespace with something useful like a TemplateHelper for various capabilities.
  • In terms of templates, are the addfieldpath and addfieldprefix attributes both going to be supported in Joomla 4+?
avatar thednp thednp - open - 4 Aug 2020
avatar joomla-cms-bot joomla-cms-bot - change - 4 Aug 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 4 Aug 2020
avatar thednp thednp - change - 4 Aug 2020
The description was changed
avatar thednp thednp - edited - 4 Aug 2020
avatar ReLater
ReLater - comment - 4 Aug 2020

Not an answer. I don't know. But

Is it just a typo inside this issue?
addfieldpreffix (2 f)
versus
addfieldprefix

avatar thednp
thednp - comment - 4 Aug 2020

Copy from my templateDetails.xml

addfieldprefix="Joomla\CMS\Plugin\EditorsXtd\Vimeo\Field"

I misspelled here only, will correct the above.

avatar thednp thednp - change - 4 Aug 2020
The description was changed
avatar thednp thednp - edited - 4 Aug 2020
avatar wilsonge
wilsonge - comment - 4 Aug 2020

Yes there's no real concept of namespaced resources for templates. However you can still use addFieldPath and addFieldPrefix from J3. Although I'm not against introducing the concept of a namespaced autoloaded area for templates either.

avatar thednp
thednp - comment - 5 Aug 2020

Yes there's no real concept of namespaced resources for templates. However you can still use addFieldPath and addFieldPrefix from J3. Although I'm not against introducing the concept of a namespaced autoloaded area for templates either.

My concerns:

  • when addfieldpath is going to be deprecated, gonna be a nightmare to update 10+ templates
  • since addfieldpath is not working with form fields defined in namespaced plugins/pluginTYPE/pluginName/Field plugin folder (I tested as writing here), I would have to do something like plugins/pluginTYPE/pluginName/fieldsLegacy for addfieldpath, but why would we have to do that?
avatar wilsonge
wilsonge - comment - 13 Aug 2020

so if you're using formfields in the plugins directory then you need to use the addfieldprefix and that should work just fine in j4. i assumed you were talking about form fields within the template itself (which of course wouldn't be autoloaded). Using a combination of addfieldpath and addfieldprefix should be fine too.

avatar thednp
thednp - comment - 13 Aug 2020

so if you're using formfields in the plugins directory then you need to use the addfieldprefix and that should work just fine in j4.

No, I said I wanna use form fileds from my plugins directory in the template form via addfieldprefix.

i assumed you were talking about form fields within the template itself (which of course wouldn't be autoloaded). Using a combination of addfieldpath and addfieldprefix should be fine too.

Also this should work with addfieldprefix currently loading only via addfieldpath and the old "namespace".

So, we need to make custom form fields to autoload via addfieldprefix in template forms.

avatar wilsonge
wilsonge - comment - 13 Aug 2020

No, I said I wanna use form fileds from my plugins directory in the template form via addfieldprefix.

That should work fine - we'll need to spend some time figuring out what doesn't work exactly here. The plugins if you've defined the namespace section should be autoloaded just fine.

avatar thednp
thednp - comment - 14 Aug 2020

I'm talking with my files in front of me, it doesn't work and you're talking "should".

avatar thednp
thednp - comment - 30 Sep 2020

@wilsonge after a while I realize I was replying here with a little bit of pressure, my apologies.

I had a type error addfieldprefix="Joomla\CMS\Plugin\EditorsXtd\Vimeo\Field" should have been addfieldprefix="Joomla\Plugin\EditorsXtd\Vimeo\Field", this works in templateDetails.xml (facepalm).

I have good news, I've implemented namespace templates with #30816, please test and report back any suggestion or idea.

Thanks and good day.

avatar brianteeman
brianteeman - comment - 25 Nov 2020

This should be closed as there is an open PR for it #30816

avatar HLeithner HLeithner - change - 25 Nov 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-11-25 13:11:08
Closed_By HLeithner
avatar HLeithner HLeithner - close - 25 Nov 2020

Add a Comment

Login with GitHub to post a comment