User tests: Successful: Unsuccessful:
Added support for a basedir attribute in JFormFieldList and JFormFieldFolderList and JFormFieldFileList. This allows the field to be configured such that the directory attribute is relative to one of several directories which can't be known ahead of time since their values can be changed by the user. Specifically, these are the JPATH_ constants and parameter values from various extension types.
Add a filelist or folderlist type field to any jform. Notice what happens when the field has a basedir attribute which may be set to any of:
component:com_media:file_path)library:joomla:param_name, note: Joomla libraries do not actually have params)module:mod_menu:some_menu_title:param_name)plugin:system:myplugin:param_name)So, here's a pretty real test:
Go to the media manager and change the location of the files and images directories.
Go to the plugin settings for 'Fields - Imagelist' plugin.
This plugin is supposed to show a list of directories in the images directory but it will not be your new custom images directory, it will always just list the contents of /images which isn't very useful.
With this patch, that field can be configured with basedir="component:com_media:image_path" and directory="/" and it should show the correct contents.
Without any basedir attribute, the directory attribute will be relative to the root of the Joomla intallation. With a basedir, it will be relative to that directory.
All good.
Maybe a little.
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
By the way, this drone failure is nonsense.
I guess it could even be better than that. We could have component:com_media:file_path and component:com_media:image_path which would basically mean that we might also use other extension types. Something like plugin:plg_whatever:some_param could be used. Is that just getting to be too much? Or would it be useful? I think not difficult at all to develop in any case.
Yes better not introduced 2 hard coded cases for com media
please add it as you suggested component:com_media:file_path,
and i will help test this
You can just add support for component parameters now
and if needed some other PR can add for plugins and modules parameters in the future
if you add for plugin it should also include folder too
plugin:search:mysearch:some_path
$ops = explode(':', $basedir);
if ($ops[0] === 'plugin' && count($ops) === 5)
{
$plugin = JPlugin::getPlugin($ops[1], $ops[2]);
$pluginParams = new JRegistry($plugin ? $plugin->params : null);
...
}
The filelist and folderlist fields do not have a connection to com_media and should not. If you want to make one which depends on com_media then you need to create your own mediafolderlist form field.
| Labels |
Added:
?
|
||
I've removed any reference to any specific component and used the more generalized method as discussed. You can get a basedir value from the params of any component, plugin, library (I know, right?), or module (OK, this one is kinda funny).
I also noticed that there are some standard joomla plugins that use this type of field with directory set to 'images'. This is obviously a problem if the user changes his images directory to something else. So those plugins are probably currently broken if you have a custom images directory. With this patch, we can fix them.
It seems to me that these two classes are 90% identical code. Could be that they should both inherit from some abstract 'filesystemitemlist' class or something like that. In fact, maybe that's not even necessary. filelist could probably inherit from folderlist and just override two or three functions. Am I wrong?
Traits could also be a solution except that they aren't available before php 5.4.
Sorry that it took so long to respond. This is here is a nice feature, unfortunately it should be added to Joomla 4. Can you rebase the pr to the 4.2-dev branch, so we can test it properly. In the meantime I'm closing the pr, when ready please reopen again. Thanks for your contribution making Joomla better.
| Status | Pending | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-25 13:52:02 |
| Closed_By | ⇒ | laoneo | |
| Labels |
Added:
?
Removed: ? |
||
One thing I'm not so sure about here is
file_pathandimage_path. Maybe they would be better ascom_media:file_pathandcom_media:image_pathso that such values could be handled in a more generic way instead of as special cases. Based on such a value we could get the params for any component and use any of its values as the base dir.I guess it could even be better than that. We could have
component:com_media:file_pathandcomponent:com_media:image_pathwhich would basically mean that we might also use other extension types. Something likeplugin:plg_whatever:some_paramcould be used. Is that just getting to be too much? Or would it be useful? I think not difficult at all to develop in any case.