Label Parsing: Difference between revisions
>Ruuk |
>NedBot m (Robot: Cosmetic changes) |
||
Line 1: | Line 1: | ||
In label controls, fadelabel controls, built-in functions as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO, $ESCINFO[] and $LOCALIZE keywords in a <label> tag. In addition to this, you can use the [[Label Formatting]] syntax to specify color and style information for the text (changeable within a single label). | In label controls, fadelabel controls, built-in functions as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO, $ESCINFO[] and $LOCALIZE keywords in a <label> tag. In addition to this, you can use the [[Label Formatting]] syntax to specify color and style information for the text (changeable within a single label). | ||
===Example=== | === Example === | ||
<source lang="xml"> | <source lang="xml"> | ||
<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label> | <label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label> | ||
Line 14: | Line 14: | ||
</source> | </source> | ||
===How the parsing works=== | === How the parsing works === | ||
#XBMC runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.xml. | # XBMC runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.xml. | ||
#XBMC then runs through and translates the $INFO[infolabel,prefix,postfix] blocks from left to right. | # XBMC then runs through and translates the $INFO[infolabel,prefix,postfix] blocks from left to right. | ||
#If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block. | # If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block. | ||
#If the Info manager returns a non-empty string from the infolabel, then XBMC prints the prefix string, then the returned infolabel information, then the postfix string. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $. | # If the Info manager returns a non-empty string from the infolabel, then XBMC prints the prefix string, then the returned infolabel information, then the postfix string. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $. | ||
#Any pieces of information outside of the $INFO blocks are rendered unchanged. | # Any pieces of information outside of the $INFO blocks are rendered unchanged. | ||
So, in the above example, if nothing is playing then the label will print: | So, in the above example, if nothing is playing then the label will print: | ||
A good example of a<br><br> | A good example of a<br /><br /> | ||
If a song is playing but it has no Title (ie MusicPlayer.Title? returns an empty string) but does have an artist, it will return: | If a song is playing but it has no Title (ie MusicPlayer.Title? returns an empty string) but does have an artist, it will return: | ||
A good example of a song artist: <Artist><br><br> | A good example of a song artist: <Artist><br /><br /> | ||
If a song is playing that has title and artist information, it will return: | If a song is playing that has title and artist information, it will return: | ||
A good example of a song title: <Title>, and a song artist: <Artist> | A good example of a song title: <Title>, and a song artist: <Artist> | ||
Line 38: | Line 38: | ||
If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter. | If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter. | ||
==See also== | == See also == | ||
'''Development:''' | '''Development:''' | ||
* [[Add-on development]] | * [[Add-on development]] |
Revision as of 15:10, 27 April 2013
In label controls, fadelabel controls, built-in functions as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO, $ESCINFO[] and $LOCALIZE keywords in a <label> tag. In addition to this, you can use the Label Formatting syntax to specify color and style information for the text (changeable within a single label).
Example
<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label>
<label>$LOCALIZE[31005]</label>
<label>The following will be localized from an addons strings - $ADDON[addon.id.here 32001]</label>
How the parsing works
- XBMC runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.xml.
- XBMC then runs through and translates the $INFO[infolabel,prefix,postfix] blocks from left to right.
- If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block.
- If the Info manager returns a non-empty string from the infolabel, then XBMC prints the prefix string, then the returned infolabel information, then the postfix string. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $.
- Any pieces of information outside of the $INFO blocks are rendered unchanged.
So, in the above example, if nothing is playing then the label will print:
A good example of a
If a song is playing but it has no Title (ie MusicPlayer.Title? returns an empty string) but does have an artist, it will return:
A good example of a song artist: <Artist>
If a song is playing that has title and artist information, it will return:
A good example of a song title: <Title>, and a song artist: <Artist>
$ESCINFO[] should be used when passing an infolabel to a built-in function, when this infolabel is likely to contain commas (,) and/or quotes (").
eg: PlayMedia($INFO[ListItem.Path]) might return: PlayMedia(/some/path/with_a_file_that_includes,a_comma.avi)
This will be read by the builtin function generator as PlayMedia called with 2 parameters: "/some/path/with_a_file_that_includes" and "a_comma.avi".
If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter.
See also
Development: