2021-07-19, 23:30
@"nfm886" , here are some excerpts from my script-skinshortcuts.xml that might help:
Next, you will see the buttons I am using for configuring widgets 1 and 2. As you will see, what I do in these buttons is set the focus to control ID 312 for widget 1, and control id 4312 for widget 2:
Also, in my case, all of the menu item properties for widget 2 end in .2, for widget 3 they end in .3, and so on. I support up to 6 widgets in Amber.
Here's the code for button 312. Notice that there is no onclick for it, since the script already knows that you configure a widget when you click on this button. I am not setting a widgetID window property for this button, so all of the widget 1 properties do not have a suffix. If you want all of your widget 1 properties to be suffixed with .1, then you can set the window property to 1.
Now, here is the code for button 4312, for widget 2. So, all you need to do is set the window property widgetID to 2 (in this example), and send a click to button 312. This should allow you to choose what you want for the widget, and the resulting path will be stored in Container(211).ListItem.Property(widgetPath.2). All of the widget 2 properties will be suffixed with .2
It is important that you tell script.skinshortcuts where to go back to from any of the buttons you use to configure widget properties, because usually Back will close the management dialog. You do this in the "overrides.xml" file in the shortcuts folder. In the example below, I am telling script.skinshortcuts to go back to button 800 from button 312 (back to the Widget 1 button), and to button 801 from button 4312 (back to the Widget 2 button):
In my template.xml, I have an include for each widget (1 through 6). In Amber, widgets are called shelves, so in the template.xml I have a "shelgroup1" include, a "shelfgroup2" include, and so on. Here is the start of the include for widget 2:
So, basically I am telling the script that include "skinshortcuts-template-shelfgroup2" needs to be generated if the menu item has a widgetPath.2 property, and in my case, if the content type (a custom property I created) is set to default (I do this to separate the static-content widgets from the dynamic content widgets; the includes for static widgets are separate).
I get the mainmenu item id, and then I also get all of the widget properties so I can use them in the include. Sort by, Sort order and Limit are set in the management dialog via separate buttons for each widget. Feel free to look at the script.skinshortcuts.xml in Amber for working examples.
To display all of my widgets, I do something like the following. The excerpt is from the "Includes_Horizontal_Home.xml" in Amber:
As you can see from the above, I include all of my six template includes for my widgets. Not necessarily each menu items has 6 widgets, or even 1. The conditions in the template.xml for each widget include determine which ones are generated for which menu item.
I hope this info is useful, and I am more than happy to answer any other questions you might have.
Please bear in mind that this is how I have done things. I am aware that this is not the most elegant or concise code, but it does work for me. @jurialmunkey has much more elegant code in his skins, and I think it would be a good idea for you to look at his code to get a better idea of what can be done. Thanks.
Regards,
Bart
Next, you will see the buttons I am using for configuring widgets 1 and 2. As you will see, what I do in these buttons is set the focus to control ID 312 for widget 1, and control id 4312 for widget 2:
xml:
<control type="button" id="800">
<visible>String.IsEqual(Window.Property(groupname),mainmenu) + !Skin.HasSetting(Hide.AllShelves)</visible>
<description>Widget</description>
<label>$LOCALIZE[31491] 1</label>
<label2>$INFO[Container(211).ListItem.Property(widgetName)]</label2>
<onfocus condition="!String.IsEmpty(Window(Home).Property(skinshortcuts-Widget))">ClearProperty(skinshortcuts-Widget,Home)</onfocus>
<onclick>SetProperty(skinshortcuts-Widget,1,Home)</onclick>
<onclick>Control.SetFocus(312)</onclick>
<height>60</height>
<width>1340</width>
<texturenofocus border="3">buttons/ButtonNF.png</texturenofocus>
<font>ListDetails</font>
<visible>!String.IsEqual(Container(211).ListItem.Property(skinshortcuts-disabled),True)</visible>
</control>
<control type="button" id="801">
<visible>String.IsEqual(Window.Property(groupname),mainmenu) </visible>
<description>Widget 2</description>
<label>$LOCALIZE[31491] 2</label>
<label2>$INFO[Container(211).ListItem.Property(widgetName.2)]</label2>
<onfocus condition="!String.IsEmpty(Window(Home).Property(skinshortcuts-Widget))">ClearProperty(skinshortcuts-Widget,Home)</onfocus>
<onclick>SetProperty(skinshortcuts-Widget,2,Home)</onclick>
<onclick>Control.SetFocus(4312)</onclick>
<height>60</height>
<width>1340</width>
<texturenofocus border="3">buttons/ButtonNF.png</texturenofocus>
<font>ListDetails</font>
<visible>!String.IsEqual(Container(211).ListItem.Property(skinshortcuts-disabled),True)</visible>
</control>
Also, in my case, all of the menu item properties for widget 2 end in .2, for widget 3 they end in .3, and so on. I support up to 6 widgets in Amber.
Here's the code for button 312. Notice that there is no onclick for it, since the script already knows that you configure a widget when you click on this button. I am not setting a widgetID window property for this button, so all of the widget 1 properties do not have a suffix. If you want all of your widget 1 properties to be suffixed with .1, then you can set the window property to 1.
xml:
<control type="button" id="312">
<label>$LOCALIZE[31491] 1</label>
<label2>$INFO[Container(211).ListItem.Property(widgetName)]</label2>
<height>60</height>
<width>1340</width>
<texturenofocus border="3">buttons/ButtonNF.png</texturenofocus>
<font>ListDetails</font>
</control>
Now, here is the code for button 4312, for widget 2. So, all you need to do is set the window property widgetID to 2 (in this example), and send a click to button 312. This should allow you to choose what you want for the widget, and the resulting path will be stored in Container(211).ListItem.Property(widgetPath.2). All of the widget 2 properties will be suffixed with .2
xml:
<control type="button" id="4312">
<label>$LOCALIZE[31491] 2</label>
<label2>$INFO[Container(211).ListItem.Property(widgetName.2)]</label2>
<onclick>SetProperty(widgetID,2)</onclick>
<onclick>SendClick(312)</onclick>
<height>60</height>
<width>1340</width>
<texturenofocus border="3">buttons/ButtonNF.png</texturenofocus>
<font>ListDetails</font>
</control>
It is important that you tell script.skinshortcuts where to go back to from any of the buttons you use to configure widget properties, because usually Back will close the management dialog. You do this in the "overrides.xml" file in the shortcuts folder. In the example below, I am telling script.skinshortcuts to go back to button 800 from button 312 (back to the Widget 1 button), and to button 801 from button 4312 (back to the Widget 2 button):
xml:
<!-- On backs for management dialog -->
<onback to="800">312</onback>
<onback to="801">4312</onback>
In my template.xml, I have an include for each widget (1 through 6). In Amber, widgets are called shelves, so in the template.xml I have a "shelgroup1" include, a "shelfgroup2" include, and so on. Here is the start of the include for widget 2:
xml:
<other include="shelfgroup2">
<!-- Widget condition: a path is needed -->
<condition tag="property" attribute="name|widgetPath.2" />
<condition tag="property" attribute="name|widgetContent.2">default</condition>
<!-- Retrieve id -->
<property name="id" tag="mainmenuid" />
<!-- Retrieve properties -->
<property name="label2" tag="property" attribute="name|widgetName.2" />
<property name="path2" tag="property" attribute="name|widgetPath.2" />
<property name="target2" tag="property" attribute="name|widgetTarget.2" />
<property name="type2" tag="property" attribute="name|widgetType.2" />
<property name="widget2" tag="property" attribute="name|widget.2" />
<property name="sortby2" tag="property" attribute="name|widgetSortBy.2" />
<property name="sortorder2" tag="property" attribute="name|widgetSortOrder.2" />
<property name="limit2" tag="property" attribute="name|widgetLimit.2" />
So, basically I am telling the script that include "skinshortcuts-template-shelfgroup2" needs to be generated if the menu item has a widgetPath.2 property, and in my case, if the content type (a custom property I created) is set to default (I do this to separate the static-content widgets from the dynamic content widgets; the includes for static widgets are separate).
I get the mainmenu item id, and then I also get all of the widget properties so I can use them in the include. Sort by, Sort order and Limit are set in the management dialog via separate buttons for each widget. Feel free to look at the script.skinshortcuts.xml in Amber for working examples.
To display all of my widgets, I do something like the following. The excerpt is from the "Includes_Horizontal_Home.xml" in Amber:
xml:
<!-- Widgets -->
<control type="group" id="700">
<include>skinshortcuts-template-shelfgroup1</include>
<include>skinshortcuts-template-shelfgroup2</include>
<include>skinshortcuts-template-shelfgroup3</include>
<include>skinshortcuts-template-shelfgroup4</include>
<include>skinshortcuts-template-shelfgroup5</include>
<include>skinshortcuts-template-shelfgroup6</include>
<control type="group">
<include>PVRRecordingWidgets</include>
</control>
</control>
As you can see from the above, I include all of my six template includes for my widgets. Not necessarily each menu items has 6 widgets, or even 1. The conditions in the template.xml for each widget include determine which ones are generated for which menu item.
I hope this info is useful, and I am more than happy to answer any other questions you might have.
Please bear in mind that this is how I have done things. I am aware that this is not the most elegant or concise code, but it does work for me. @jurialmunkey has much more elegant code in his skins, and I think it would be a good idea for you to look at his code to get a better idea of what can be done. Thanks.
Regards,
Bart