Skip to Content Skip to Menu

default values for plugin parameters

  • kmchen
  • kmchen
  • OFFLINE
  • Posts: 17
  • Thanks: 0
  • Karma: 1
14 years 11 months ago #116566 by kmchen
default values for plugin parameters was created by kmchen
Hi
I developped a plugin with default parameters declared this way:

[code:1] <params>
<param name="@spacer" type="spacer" label="Credits:" default="This plugin was created by Thierry Chen for POSTGATE enterprises" description="" />
<param name="@spacer" type="spacer" label="License:" default="This plugin is distributed under a limited GNU/GPL license and cannot be modified to work with anything else outside of the Community Builder suite supported by the Joomlapolis.com site" description="" />
<param name="@spacer" type="spacer" label="Parameters:" default="Please look at the relevant tab for additional parameters" description="" />
<param name="thumbs_width" type="text" default="76" label="Profile thumbs width" description="Profile thumbs width for portfolios images. Live empty to avoid resizing" />
<param name="no_image" type="text" default="components/com_comprofiler/plugin/user/plug_profileimage/images/no-image-76x76.jpg" label="No image file url" description="No image file url(from Joomla root)" />
<param name="pi_folder" type="text" default="images/comprofiler/profileimage" label="Images folder" description="Where profile images are stored. Each directory represents an og the 9 items. Each jpg file in folders represents a value for the item" />
</params>
[/code:1]

The problem is that this default values are written in database only after a user goes to the plugin manager and saves the plugin once (even setting no parameters).
Is there an issue ?

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
14 years 11 months ago #116571 by nant
Replied by nant on topic Re:default values for plugin parameters
Not really an issue.

Your plugin should have default values set for each parameter.

Look at CB Gallery plugin for examples.

Please Log in or Create an account to join the conversation.

  • kmchen
  • kmchen
  • OFFLINE
  • Posts: 17
  • Thanks: 0
  • Karma: 1
14 years 11 months ago #116628 by kmchen
Replied by kmchen on topic Re:default values for plugin parameters
You don't see default values in that statement ? :

[code:1]<param name="thumbs_width" type="text" default="76" label="Profile thumbs width" description="Profile thumbs width for portfolios images. Live empty to avoid resizing" />
[/code:1]

Default value "76" is takes effect only when some administrator saves the plugin once in backend.

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
14 years 11 months ago #116630 by nant
Replied by nant on topic Re:default values for plugin parameters
kmchen wrote:

You don't see default values in that statement ? :

[code:1]<param name="thumbs_width" type="text" default="76" label="Profile thumbs width" description="Profile thumbs width for portfolios images. Live empty to avoid resizing" />
[/code:1]

Default value "76" is takes effect only when some administrator saves the plugin once in backend.


In your php file you should have something like this:

[code:1]$params->get('thumbs_width', 76)[/code:1]

This way when your code actually uses the parameter it will default to same 76 value in case the parameter is not set in database.

Please Log in or Create an account to join the conversation.

  • kmchen
  • kmchen
  • OFFLINE
  • Posts: 17
  • Thanks: 0
  • Karma: 1
14 years 11 months ago #116633 by kmchen
Replied by kmchen on topic Re:default values for plugin parameters
Thanks a lot Nick. It works that way.

But isn't it a little heavy to have default definitions in xml and php files ? Each time one wants to modifie a default value he has to replace all occurences in whole files...:sick:

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
14 years 11 months ago #116635 by nant
Replied by nant on topic Re:default values for plugin parameters
kmchen wrote:

Thanks a lot Nick. It works that way.

But isn't it a little heavy to have default definitions in xml and php files ? Each time one wants to modifie a default value he has to replace all occurences in whole files...:sick:


Well, that's how things currently work.

Pretty sure that Joomla has similar concept (could be wrong, but think so).

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum