PDA

View Full Version : Plugin api settings pages ?



erland
2007-09-27, 22:00
I've started the Custom Scan plugin conversion, and have a question regarding the api for implementing settings for your plugin.


When you define a Settings class that inherits from Slim::Web::Settings it automatically registers a menu item that appears in the "Server Setttings" droplist.
Is there some way I could connect my own page to this droplist element and still have a Settings class ?

I would like "Server Settings/Custom Scan" to go to: plugins/CustomScan/customscan_list.html
And I would like to have "Settings" link on the "customscan_list.html" page that go to: plugins/CustomScan/settings/basic.html

plugins/CustomScan/settings/basic.html is the page that is connected to the Settings class that inherits Slim::Web::Settings.

plugins/CustomScan/customscan_list.html is not connected to a Settings class. This page doesn't have any settings, it contains functions to start/stop the scanning modules. Due to this I feel that it really belongs under "Server Settings" and not under the "Extras" entry on the home page.

I'm sure I can solve this in some way. I can always implement my own version of Slim::Web::Settings, but I thought there might be some plan about how things like this should be handled.

Is there some way I could accomplish what I want ?

I'll attach a screen dump of the different pages so you can get a feel how they look like. I basically want the pages to look like this but I want to "Server Settings/Custom Scan" menu to be connected to the customscan_list page and not to the settings page. The user will navigate to the settings page by using the settings link on the customscan_list page. The image to the left is "settings" and the one to the right is "customscan_list".

mherger
2007-09-27, 23:47
> Is there some way I could connect my own page to this droplist element
> and still have a Settings class ?

So you basically don't want the settings drop down to go to the settings
page, but else where? And have a link on that other page back to the
settings? I don't get the picture.

In SC7 the settings will be visually more distinct from the rest of the
application than before. While in SS6 it's no problem linking to any page
from within the settings, in SC7 the settings are in a new window,
different color set, etc. I'm not sure whether your plan fits in to this
idea very well.

--

Michael

-----------------------------------------------------------------
http://www.herger.net/SlimCD - your SlimServer on a CD
http://www.herger.net/slim - AlbumReview, Biography, MusicInfoSCR

erland
2007-09-28, 00:22
> Is there some way I could connect my own page to this droplist element
> and still have a Settings class ?

So you basically don't want the settings drop down to go to the settings
page, but else where? And have a link on that other page back to the
settings? I don't get the picture.


Yes, the plugin have two pages that belongs under "Server Settings"

- customscan_list:
A page that let you start the different scanning modules. In the same way as the SlimServer scanning is started under Server Settings I felt that this would also be appropriate for the Custom Scan plugin scanning modules. However, the customscan_list page doesn't really have any attributes that needs to be save, it just contains commands to start/stop/clear scanning data. Due to this it isn't a real settings page that need a "Save Settings" button at the bottom and the other settings page features available for every page which handler inherits Slim::Web::Settings

- settings:
A page that contains options that change the behaviour of the scanning modules. This page has a handler that inherits from Slim::Web::Settings and this also results that this is the page that appears in the drop list in Server Settings.

The user are most of the time going to want to go into the customscan_list page, so due to this I would like this page to be shown first. So I want customscan_list to be linked to "Server Settings/Custom Scan" and I want to have a "Settings" link on that page that links further to the "settings" page in case the user likes to change the behaviour of the scanning modules.

Did that make any sense ?

kdf
2007-09-28, 00:44
On 28-Sep-07, at 12:22 AM, erland wrote:

> page that need a "Save Settings" button at the bottom and the other
> settings page features available for every page which handler inherits
> Slim::Web::Settings

It doesn't have to have the "save settings" link. that comes from
calling SUPER::handler from the subclass handler.
However, they do get included in the pulldown. If you don't want
that, you can use addPageLinks to create the handler reference
and link from your main page to the second, and write the handler to
deal with that.

Take a look at Felix's IRBlaster plugin. It's a good example of
multiple settings pages and it has a version that works with 7.0

-kdf

Craig, James \(IT\)
2007-09-28, 02:00
> - customscan_list:
> A page that let you start the different scanning modules.

Erland, sounds to me like this page should appear under the Custom Scan
plugins own menu/interface entry?

James
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

erland
2007-09-28, 05:00
> - customscan_list:
> A page that let you start the different scanning modules.

Erland, sounds to me like this page should appear under the Custom Scan
plugins own menu/interface entry?

I'm not sure I understand what you mean

In SlimServer 6.5 the structure looks like this:


Home
Plugins
Custom Scan (this is the customscan_list page)
Server Settings
Plugins (here the settings page is shown as a Custom Scan section in the large plugin settings page)


It has always looked wrong to have Custom Scan directly under the Plugins menu in the Home menu. The reason is that this is basically a settings plugin which is never relevant to use when you listen och browse through your library. You will configure it once and after this you will never see it.

The plan I had for 7.0 was to instead have a structure like:


Home
Plugins
Server Settings
Custom Scan (this would be the customscan_list page)
Settings (this would be the settings page)


By default SlimServer 7.0 makes it easy to have structure like below, but this feels a bit incorrect since the most time a user wants to access the Custom Scan plugin he probably wants to the customscan_list page.


Home
Plugins
Server Settings
Custom Scan (this would be the settings page)
Manage scanning (this would be the customscan_list page)

Craig, James \(IT\)
2007-09-28, 05:07
Can't you just switch the pages over ?

James
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

erland
2007-09-28, 10:40
On 28-Sep-07, at 12:22 AM, erland wrote:

> page that need a "Save Settings" button at the bottom and the other
> settings page features available for every page which handler inherits
> Slim::Web::Settings

It doesn't have to have the "save settings" link. that comes from
calling SUPER::handler from the subclass handler.
However, they do get included in the pulldown. If you don't want
that, you can use addPageLinks to create the handler reference
and link from your main page to the second, and write the handler to
deal with that.

Take a look at Felix's IRBlaster plugin. It's a good example of
multiple settings pages and it has a version that works with 7.0

-kdf
I didn't get the IRBlaster plugin to work, it doesn't seem to be updated with the Slim::Utils:Prefs changes.

Anyway, I got it partly to work as I like by not calling $class->SUPER::new() in the "settings" page (The one I didn't want in the droplist)

However, one problem still remains to get the optimal solution. I would like the drop list to show "Custom Scan" independent on which of the pages I select. Since only one of the pages appears in the drop list this doesn't work. If I choose the one that appears in the drop list everything looks ok, but if I choose the other one the drop list is reset back to "Basic Settings". Is there some way I from the handler or HTML template can force a specific item to be selected in the drop list at the top ?
I tried to assign the $paramRef->{'page'} to the other page inside the handler, but that didn't seem to make any difference.

erland
2007-09-28, 11:30
I
However, one problem still remains to get the optimal solution. I would like the drop list to show "Custom Scan" independent on which of the pages I select. Since only one of the pages appears in the drop list this doesn't work. If I choose the one that appears in the drop list everything looks ok, but if I choose the other one the drop list is reset back to "Basic Settings". Is there some way I from the handler or HTML template can force a specific item to be selected in the drop list at the top ?
I tried to assign the $paramRef->{'page'} to the other page inside the handler, but that didn't seem to make any difference.

I think I solve this, it seems to work if I set the page attribute like this on the top of the html templates. I'm not sure if it have any side effects yet, though.


[% page = "PLUGIN_CUSTOMSCAN" %]
[% PROCESS settings/header.html %]

kdf
2007-09-28, 11:39
I'm not sure if it have any side effects yet, though.


That's basically the way it works, so you'll be ok. The only thing is that if you want users to be able to go back and forth, make sure you have a link to do so. The server will not be able to tell the difference and the pulldown doesn't let you reselect the current page.
-kdf