[com_fields] Move custom field types to plugin#13319
Conversation
|
I have tested this item ✅ successfully on 47f11c0 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13319. |
| $path = JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/layouts'; | ||
|
|
||
| // Prepare the value from the type layout | ||
| return JLayoutHelper::render('field.prepare.' . $field->type, array('field' => $field), $path); |
There was a problem hiding this comment.
I think having a folder structure plugins/fields/foo/layouts/fields/prepare/foo.php is a bit to much.
Do we really need the prefix field.prepare. for the layout path? I'd say field is a given anyway since it's located in the plugins/fields/foo/layouts directory. The prepare is likely superfluous as well.
Without that it would come down to plugins/fields/foo/layouts/foo.php.
I'd also say the layout name could be just default.php because in most cases we expect only one layout per plugin anyway. If there are multiple, it needs custom code anyway.
There was a problem hiding this comment.
I would put it into a folder, otherwise the layout override in the template would be /templates/protostar/html/layouts/foo.php which is not optimal.
There was a problem hiding this comment.
Maybe instead of using JLayoutHelper::render() we can use JPluginHelper::getLayoutPath() here? Then the layouts would go into the tmpl folder instead.
Similar to how it is done for the vote and pagenavigation plugin.
Then the override path would be html/plg_fields_text/default.php
There was a problem hiding this comment.
Didn't know this exists, that's much better.
There was a problem hiding this comment.
@Bakual although is possible to get the layout in the plugin html/plg_fields_text/default.php personally I would prefer the layouts to be in the root/layouts folder under joomla/custom_fields
e.g. layous/joomla/custom_fields/text.php
There was a problem hiding this comment.
Two things about the /layouts folder:
- The layouts folder should only be used for reusable JLayouts. I don't think that0s the case for most of them.
- The layouts folder can't be used by 3rd party extensions without specific code in your install script that moves the files there. So it would give a wrong example.
| // Gather the type | ||
| $type = $form->getValue('type'); | ||
|
|
||
| if (isset($formData->type) && $formData->type) |
There was a problem hiding this comment.
Personal oppinion: Using if (!empty($formData->type) would do the exact same thing and is easier to read (once you get used to the "double negation" 😄 ).
There was a problem hiding this comment.
If the the attribute type would not exist on $formData, a notice would be thrown.
There was a problem hiding this comment.
Nah, empty() has an implied isset() check and doesn't throw a notice if the property doesn't exist. It does exactly what you did in two statements.
See http://php.net/manual/en/function.empty.php
Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.
|
I very much like this PR. It makes fetching the fields so much easier to understand. Thank you! 👍 |
|
Should we put all fields into this PR, or should I do for every field a new one? The installer script needs then to be adjusted for every PR then, which will cause conflicts in other PR's which do change the installer sql files. |
|
I'd do all types in this PR. There will be no conflicts in the new files anyway and the other file changes are already in this PR. This PR needs the install and update SQLs to register the added plugins and its default parameter values then. |
|
please also, do not forget to modify en-GB install.xml for any new plugin |
…la-cms.git into fields-text-plugin
47f11c0 to
1116b01
Compare
|
@Bakual what do you think about the latest commit? Stuff is moved to layout as the other plugins and the field parameters are inherited now from the plugin. If there are no more concerns, I will start to move the other ones. |
| } | ||
|
|
||
| // Ensure it is an object | ||
| $formData = (object)$data; |
There was a problem hiding this comment.
Travis is complaining about a missing space $formData = (object) $data;
| // Gather the type | ||
| $type = $form->getValue('type'); | ||
|
|
||
| if(!empty($formData->type)) |
|
A few remarks concerning lang strings:
PLG_FIELDS_TEXT="Fields - Text"
PLG_FIELDS_TEXT_XML_DESCRIPTION="The Text Fields plugin."and for gallery PLG_FIELDS_GALLERY="Fields - Gallery"
PLG_FIELDS_GALLERY_XML_DESCRIPTION="The Gallery Fields plugin."
PLG_FIELDS_TEXT_FIELDPARAMS_USE_GLOBAL="Use From Plugin"instead of PLG_FIELDS_TEXT_PARAMS_USE_GLOBAL="Use From Plugin" |
https://laoneo@github.com/Digital-Peak/joomla-cms.git into fields-text-plugin Conflicts: administrator/components/com_fields/helpers/fields.php administrator/components/com_fields/helpers/internal.php administrator/components/com_fields/models/field.php administrator/components/com_fields/models/fields/type.php libraries/joomla/form/field.php plugins/fields/gallery/layouts/field/prepare/gallery.php
|
Like 368042d ? |
|
Concerning alpha order, it now looks fine. Thanks. Question: |
|
Oh, forgot |
|
There is no text for PLG_FIELDS_GALLERY_XML_DESCRIPTION. |
|
Is it possible to show the configuration values set in the fields and system plugin? |
|
There is already an issue open for the global value: #13350 |
|
Frontend lib file is changed.
Because the JFormFieldList is not loaded automatically so I'v added the import to all fields which are extending list as I converted them back from abstractlist. |
|
Gallery string is created, thanks for the hint @waader. |
|
Finally found some time to test this. @rdeutz Imho it could be merged to get the architecture right for the alpha2 and then fix the remaining bugs afterwards. As for the findings in detail:
|
|
Thanks @Bakual. Give me some days to fix the bugs, except the first one. |
|
Imho those are all minor issues with the respective plugins and could be fixed after this is merged (to not delay this one). But I leave that for others to decide :) |
|
I have tested this item ✅ successfully on 2ccdcd7 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13319. |
|
I have tested this item ✅ successfully on 2ccdcd7 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13319. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13319. |
* [plugins] - fields mssql installation plugins fields mssql installation #13616 * [com_fields] - mssql updates #13319 [com_fields] - mssql updates #13319 * remove duplicate extension id 462 for mssql removed id 462 to avoid duplicated id with #13626 cause now fields are managed with plugins Pull Request for Issue #13616 (comment)
Pull Request for Issue #13227. It moves all the custom field types to their own plugin.
Summary of Changes
The text custom field type is moved to it's plugin. The JFormdomfieldinterface is removed.
onCustomFieldsGetTypes.onCustomFieldsPrepareFieldevent.onCustomFieldsPrepareDom.If you are loading this PR trough the patch tester you need to discover the plugins first in the extension manager.
Testing Instructions 1
Expected Result 1
Testing Instructions 2
Expected Result 2
The field should not be shown in the edit form and on the front end.
Documentation Changes Required
None, as there is no documentation already for custom fields.