<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

PluginWebInterface

From SqueezeboxWiki

Revision as of 07:08, 23 June 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

SqueezeCenter Plugins can expose their own web interface, accessible through the main server's web pages. To do this, include a function called "webPages" which adds page handlers and can link them to certain menus.

There are two important calls you can do: - Slim::Web::HTTP::addPageFunction(): add a page handler - Slim::Web::Pages->addPageLinks(): add a page link to some given places

Example 6:

sub webPages { 
    Slim::Web::HTTP::addPageFunction("plugins/MyPlugin/enable.html",  \&handleEnable);
    Slim::Web::Pages->addPageLinks('plugins', {"plugins/MyPlugin/index\.(?:htm|xml)", \&handleIndex} ); 
}

The handler definition is always a pair of information: an url (which can be a regular expression) and reference to a sub handling the request.

Plugins also have the option of adding links to other sections of the SqueezeCenter index page. Specifically, links can be added to the "browse", "search", "settings", "plugins" and "help" sections. Note that not all skins may support every section. Links can be added using the /Slim::Web::Pages->addPageLinks()/ method. The method takes two parameters: the category to which links should be added, and a reference to a hash that maps link text to a URL path. In this case, the URL path must include the "plugins/<pluginname>/" prefix.

Next Page