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).
I think I remember that LMS already has some logic for that but I don't know where I saw that...Code:[ { 'id' => 129, 'name' => 'AAAAA', 'chosen' => '' }, { 'name' => 'BBBBB', 'chosen' => '', 'id' => 132 }, { 'chosen' => '', 'name' => 'CCCC', 'id' => 140 }, (...) ]
So before reinventing the wheel I thought I'd ask... Thank you.
Results 1 to 10 of 24
Thread: html template documentation?
-
2021-03-01, 06:14 #1
- Join Date
- Jul 2010
- Posts
- 219
html template documentation?
-
2021-03-01, 07:08 #2
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)
-
2021-03-01, 12:24 #3
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 )
-
2021-03-01, 12:54 #4
- Join Date
- Jul 2010
- Posts
- 219
Thanks Michael. That's exactly what I was looking for.
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.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>
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>
-
2021-03-01, 13:43 #5
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 )
-
2021-03-02, 05:40 #6
- Join Date
- Jul 2010
- Posts
- 219
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>
Slim::Web::Template::SkinManager::_fillTemplate (345) Error: plugin error - table plugin failed: invalid table data, expecting a list
-
2021-03-02, 08:43 #7
- Join Date
- Jul 2010
- Posts
- 219
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?
-
2021-03-02, 09:17 #8
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.
-
2021-03-02, 09:41 #9
- Join Date
- Jul 2010
- Posts
- 219
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?
-
2021-03-02, 11:58 #10
- Join Date
- Jul 2010
- Posts
- 219
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
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.