Dynamic Fields In Plugin

19 views
Skip to first unread message

Russ Winter

unread,
Feb 8, 2018, 4:13:50 PM2/8/18
to joomla-de...@googlegroups.com
Hey Folks,

Is it possible to dynamically generate fields in a plugin?

What I would like to achieve is to use JFolder to read through a directory and acquire a list of it's sub-directories, then on the plugins page display that list of discovered folders with an option.

Within a plugins XML file I don't think you can use any form of for/foreach and each field is normally hardcoded, but in this case the folder list to be displayed would be different depending on the site.

Thanks for any assistance or bright idea's, appreciate your time,

--
Regards,
Russ Winter




Michael Babker

unread,
Feb 8, 2018, 4:42:17 PM2/8/18
to joomla-de...@googlegroups.com
Depending on what you're doing:

- User chooses a directory (single option), use folder list
- User can dynamically choose X directories, use subform plus folder list
- User sets an option per discovered directory (and you list each directory inline), create a JFormField subclass with your needed logic (though I have to admit as I type this I don't know how well you'd be able to handle the data storage of this one, you might need to hook into other plugin events during the save process to make sure it's all stored right)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Russ Winter

unread,
Feb 8, 2018, 5:35:25 PM2/8/18
to joomla-de...@googlegroups.com
thanks for the reply Michael, i'll have more of a tinker with the subclass..

the plan was to list sub-directories, each on a separate line (field) with a enable/disable toggle option next to each folder.

We work with a lot of overrides and acquire support requests to update or fix overrides, so we were just thinking of building a "quick and dirty" and simple method of enabling/disabling (effectively just renaming the folder) as an aid to troubleshooting and temporarily reverting a view back to the components default view without the need to keep FTP'ing in to rename a view. 


EG: list all the overrides and views in the current /html/ folder of the template

/html/com_component1/
/html/com_component1/view1
/html/com_component1/view2
/html/com_component2/
/html/com_component2/view1
/html/com_component2/view2


Plugin Page:

Component 1     [Enable | Disable]
 - View1              [Enable | Disable]
 - View2              [Enable | Disable]

Component 2     [Enable | Disable]
 - View1              [Enable | Disable]
 - View2              [Enable | Disable]

A plugin seemed to be the cleanest, lightest and simplest way until I started looking in to it more LOL

Thanks again,
Russ



--
Regards,
Russ Winter





On 9 February 2018 at 07:42, Michael Babker <michael...@gmail.com> wrote:
Depending on what you're doing:

- User chooses a directory (single option), use folder list
- User can dynamically choose X directories, use subform plus folder list
- User sets an option per discovered directory (and you list each directory inline), create a JFormField subclass with your needed logic (though I have to admit as I type this I don't know how well you'd be able to handle the data storage of this one, you might need to hook into other plugin events during the save process to make sure it's all stored right)
On Thu, Feb 8, 2018 at 3:13 PM, Russ Winter <wint...@gmail.com> wrote:
Hey Folks,

Is it possible to dynamically generate fields in a plugin?

What I would like to achieve is to use JFolder to read through a directory and acquire a list of it's sub-directories, then on the plugins page display that list of discovered folders with an option.

Within a plugins XML file I don't think you can use any form of for/foreach and each field is normally hardcoded, but in this case the folder list to be displayed would be different depending on the site.

Thanks for any assistance or bright idea's, appreciate your time,

--
Regards,
Russ Winter




--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsubscribe@googlegroups.com.

To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages