Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1
    Senior Member
    Join Date
    Jul 2010
    Posts
    220

    html template documentation?

    Hi.

    Can someone please point me to a more detailled documentation on html templates (esp. a list of all the template tags I can use)?

    I have an array of hashes I want to display in a table with 4 hashes / names with checkboxes in every row (4 columns).
    Code:
    [
      {
    	'id' => 129,
    	'name' => 'AAAAA',
    	'chosen' => ''
      },
      {
    	'name' => 'BBBBB',
    	'chosen' => '',
    	'id' => 132
      },
      {
    	'chosen' => '',
    	'name' => 'CCCC',
    	'id' => 140
      }, (...)
    ]
    I think I remember that LMS already has some logic for that but I don't know where I saw that...
    So before reinventing the wheel I thought I'd ask... Thank you.

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,530

    html template documentation?

    > Can someone please point me to a more detailled *documentation on html
    > templates* (esp. a *list of all the template tags* I can use)?


    LMS is using the Template Toolkit for Perl
    (http://template-toolkit.org/docs/ind..._Documentation)

  3. #3
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,285
    Quote Originally Posted by afriend View Post
    I think I remember that LMS already has some logic for that but I don't know where I saw that...
    So before reinventing the wheel I thought I'd ask... Thank you.
    Not sure if this helps but it sounds like you want to accomplish something similar as the LMS Settings/Plugins tab which is implemented here:
    https://github.com/Logitech/slimserv...asic.html#L142

    pluginGroup and pluginDetails which are used in WRAPPER and PROCESS commands are defined with the BLOCK command higher up in the same file. Defining things with BLOCK command is useful to increase readability or if you want to use similar html in several places.

    There are som standard BLOCK defined in the following file which you can also reuse, not sure if all are compatible between different LMS releases though so if you want to use them it might be worth to ask if they all can be considered stable/backward compatible first:
    https://github.com/Logitech/slimserv...EN/cmdwrappers
    I know I use contentcontainer and contentitem in some of my plugins to get similar look and feel as rest of LMS UI but Iĺm not sure they are appropriate for your use case.
    Erland Isaksson (My homepage)
    Developer of many plugins/applets
    Starting with LMS 8.0 I no longer support my plugins/applets (see here for more information )

  4. #4
    Senior Member
    Join Date
    Jul 2010
    Posts
    220
    Thanks Michael. That's exactly what I was looking for.

    Quote Originally Posted by erland View Post
    Not sure if this helps but it sounds like you want to accomplish something similar as the LMS Settings/Plugins tab which is implemented here:
    https://github.com/Logitech/slimserv...asic.html#L142

    pluginGroup and pluginDetails which are used in WRAPPER and PROCESS commands are defined with the BLOCK command higher up in the same file. Defining things with BLOCK command is useful to increase readability or if you want to use similar html in several places.

    There are som standard BLOCK defined in the following file which you can also reuse, not sure if all are compatible between different LMS releases though so if you want to use them it might be worth to ask if they all can be considered stable/backward compatible first:
    https://github.com/Logitech/slimserv...EN/cmdwrappers
    I know I use contentcontainer and contentitem in some of my plugins to get similar look and feel as rest of LMS UI but I’m not sure they are appropriate for your use case.
    The example from the first post is actually about genres that users can exclude from DPL smart playlists and DSTM mixes.
    Everyting behind the scenes is already working.
    I only need to figure out the presentation part, in a way that makes good use of screen space if you have a huge number of genres. It's probably 3 or 4 genres per row.
    So I've found this in SQLplaylist:

    Code:
    <table border="0">[% USE table parameter.values, cols=3, pad=0 %]
    	[%- FOREACH itemrow = table.rows %]
    		<tr>
    		[%- FOREACH item = itemrow %]
    			[%- itemid = "itemparameter_" _ parameter.id _ "_" _ item.id %]
    			[%- IF not loop.first %]
    				<td>[% nbsp = "&nbsp"; nbsp.repeat(10) %]</td>
    			[%- END %]
    			<td><input type="checkbox" name="[% itemid %]" id="[% itemid %]" value="1" [% parametervalue ? "checked" : "" %]>
    			<label for="[% itemid %]">[% item.name | html %]</label></td>
    		[%- END %]
    		</tr>
    	[%- END %]
    </table>
    Right now I have this boring simple list:
    Code:
    <table border="0">
    	[% FOREACH excludedgenre = excludedgenrelist %]
    	<tr>
    		<td>
    			<input type="checkbox" name="pref_excludedgenre_[% excludedgenre.id %]" id="[% excludedgenre.id %]" value="1" [% excludedgenre.chosen ? "checked" : "" %]>
    			<label for="[% excludedgenre.id %]">[% excludedgenre.name  %]</label>
    		</td>
    	</tr>
    	[% END %]
    <table>
    I'll have to take another look at BLOCK but I'm not sure if it can do these 2 nested loops you did in SQLplaylist.

  5. #5
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,285
    Quote Originally Posted by afriend View Post
    I'll have to take another look at BLOCK but I'm not sure if it can do these 2 nested loops you did in SQLplaylist.
    Random Mix plugin implementation of genre selection is here if it helps:
    https://github.com/Logitech/slimserv...list.html#L131

    Might not be worth to define a BLOCK if you use it in a single place.
    Erland Isaksson (My homepage)
    Developer of many plugins/applets
    Starting with LMS 8.0 I no longer support my plugins/applets (see here for more information )

  6. #6
    Senior Member
    Join Date
    Jul 2010
    Posts
    220
    Quote Originally Posted by erland View Post
    Random Mix plugin implementation of genre selection is here if it helps:
    https://github.com/Logitech/slimserv...list.html#L131
    Thank you. I'd actually tried that variation before with this code:

    Code:
    <table border="0" width="100%">[% USE table (excludedgenrelist, cols=3, pad=0) %]
    	[%- FOREACH genrerow = table.rows %]
    		<tr>
    			[%- FOREACH excludedgenre = genrerow %]
    			<td>
    				<input type="checkbox" name="pref_excludedgenre_[% excludedgenre.id %]" id="[% excludedgenre.id %]" value="1" [% excludedgenre.chosen ? "checked" : "" %]>
    				<label for="[% excludedgenre.id %]">[% excludedgenre.name | html %]</label>
    			</td>
    			[%- END %]
    		</tr>
    	[%- END %]
    </table>
    And it did give me the 3 columns I wanted. But I guess I didn't use it because it always reported an error (even though it did the job):
    Slim::Web::Template::SkinManager::_fillTemplate (345) Error: plugin error - table plugin failed: invalid table data, expecting a list
    Either it's unhappy with the way the array of hashes I mentioned in the first post is built or I haven't got the html template syntax part right yet...

  7. #7
    Senior Member
    Join Date
    Jul 2010
    Posts
    220
    And another little problem, again with special characters.

    Apart from the mentioned error message the genre list generated by HTML::Template doesn't display special characters correctly.
    So I get "Fran├ƒ┬žais" instead of "Franšais", for example.

    I don't care about saving the name with garbage in the preferences, as long as it's always the same garbage LMS will know it's the same genre and filter accordingly.

    But I'd very much like to display the genre names correctly on the settings page.
    Any idea how to solve this?

  8. #8
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,530

    html template documentation?

    > Apart from the mentioned error message the genre list generated by
    > HTML::Template doesn't display special characters correctly.
    > So I get "Fran├âƒ├é┬žais" instead of "Fran├žais", for example.


    You'll have to handle this in the plugin, when you read the data from
    the database (if you do so). In the CLI queries code we deo
    utf8::decode($name) etc.


  9. #9
    Senior Member
    Join Date
    Jul 2010
    Posts
    220
    Quote Originally Posted by mherger View Post
    > Apart from the mentioned error message the genre list generated by
    > HTML::Template doesn't display special characters correctly.
    > So I get "Fran├ââ├é┬žais" instead of "Fran├žais", for example.


    You'll have to handle this in the plugin, when you read the data from
    the database (if you do so). In the CLI queries code we deo
    utf8::decode($name) etc.
    Must have done it wrong, it always gave me "1" before. But now I've found a subroutine for that and the genre names are displayed as they should.

    For internal purposes LMS seems to be ok with genre names with the garbage characters (not decoded). When I save them with garbage characters to preferences and retrieve them from there to exclude genres in DSTM mixes or other playlists.
    So for internal puroses that should be ok, no?

    BTW do you have any idea how I can get rid of the html::template error message mentioned in post 6?
    Or should I just ignore that?

  10. #10
    Senior Member
    Join Date
    Jul 2010
    Posts
    220
    About the HTML::Template table plugin error:
    Slim::Web::Template::SkinManager::_fillTemplate (345) Error: plugin error - table plugin failed: invalid table data, expecting a list
    I've pushed the code to github and the relevant parts are here:
    dstm.pm and dstm.html

    As I've said, it does the job of filling the table but always logs that error.
    Last edited by afriend; 2021-03-03 at 06:28.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •