Skip to content

Skin Viewtype Builder

jurialmunkey edited this page Nov 15, 2023 · 2 revisions

Skin Viewtype Builder

script.skinvariables also provides the ability to build viewtype rule expressions. These will allow you to lock viewtypes to specific rules in the library and in plugins.

Definitions

Create a file called skinviewtypes.json in the skin's shortcuts folder.

{
    "prefix": "Exp_View",
    "viewtypes": {
        "50":  "List",
        "51":  "Banner",
        "52":  "Poster"
    },
    "rules": {
        "movies": {
            "rule": "Container.Content(movies)",
            "viewtypes": ["52"],
            "library": "52",
            "plugins": "50"
        },
        "tvshows": {
            "rule": "Container.Content(tvshows)",
            "viewtypes": ["51", "52"],
            "library": "51",
            "plugins": "50"
        },
        "other": {
            "rule": "!Container.Content(movies) + !Container.Content(tvshows)",
            "viewtypes": ["50"],
            "library": "50"
        }
    }
}

Generating Expressions

Add <onload>RunScript(script.skinvariables,action=buildviews)</onload> to Home.xml

This will generate a file in your skin's xml folder called script-skinviewtypes-includes.xml You should include this file in your Includes.xml

In the file it will generate an expression for each defined viewtype ID using the name {prefix}_{id} e.g. <expression name="Exp_View_50">{viewtype_expression}</expression>

Use these expressions in place of visibility conditions for your viewtypes
e.g. <visible>$EXP[Exp_View_50]</visible> for container ID 50.

In the "rules" section, you define the rules for each viewtype:

Key Meaning
"rule" The visibility condition to be used
"viewtypes" Which view IDs the user can select from for this rule
"library" Which view ID is set as default for this rule
"plugins" Optional. Sets a different default view for this rule if a plugin

When the script runs it will generate the expressions based upon the rules.

Changing Views

To allow the user to choose a new ID for the movies rule, you would run this command Runscript(script.skinvariables,action=buildviews,contentid=movies)

To change it for a specific plugin, you can also specify the pluginname: Runscript(script.skinvariables,action=buildviews,contentid=movies,pluginname=plugin.video.themoviedb.helper) You can also use library or plugins as the pluginname.

Configuration Dialog

You can present the user with a configuration dialog to configure available views with runscript(script.skinvariables,action=buildviews,configure)

You can also use the contentid and pluginname params to configure only a specific subset (e.g. All views for "Movies" or only "library" views or only views for a specific plugin.