XML v2.0
Create a sidebar navigation that's more elaborate and dynamic.
As seen in the previous section, Custom sidebar, XML v2.0 introduces a more modular and dynamic structure to the sidebar. The root <tree>
now divides content into an optional set of asidepanel
elements and a body
, each with their own sections. The enhanced asidepanel
supports dynamic content loaded via HTTP requests and JSONPath parsing, enabling a more flexible and user-aware sidebar.
XML Syntax
The custom sidebar uses XML to map UI elements to code, which is the engine that allows the creation of a sidebar tailored to a specific application.
The available XML elements, and their hierarchy, are:
├── tree
│ ├── asidepanel
│ │ ├── (Option A: static)
│ │ │ └── section
│ │ │ ├── menu
│ │ │ │ └── item
│ │ │ ├── link
│ │ │ ├── text
│ │ │ └── divider
│ │ ├── (Option B: dynamic using attributes)
│ │ │ └── [HTTP source + query + path → resolved into link]
│ └── body
│ └── home
│ └── section
│ ├── menu
│ │ └── item
│ ├── link
│ ├── text
│ └── divider
Using these XML elements comes with rules that are enforced by the editor and warns you of errors in the syntax:
The XML needs to start with:
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu XML V2.0//EN' "-">
.The
<tree>
element is mandatory. It must have at least 1<body>
element.<asidepanel>
is optional and there can be as many as needed.<asidepanel>
can be static or dynamic, in which case the contents are loaded through HTTP and parse based on the element attributes.The
<body>
must have at least 1<section>
.<section>
must have at least 1<menu>
or<link>
.<menu>
must have at least 1<item>
.
Here's a quick summary of the available elements and their attributes, but you can click the links and read more details:
tree
Parent element wrapping the body
and the optionals asidepanel
:
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu XML V2.0//EN' "-">
<tree>
<!--Your body and optionals asidepanel elements go here-->
</tree>
asidepanel
This element creates a static or dynamic, user-aware content asidepanel.
These are the attributes of the asidepanel
element:
id
Used to associate the asidepanel with the respective link
or item
elements from which the asidepanel will be invoked.
source
Ubidots API endpoint path or external URL from which the content of the asidepanel will be retrieved dynamically through and HTTP request.
text
This is the title of the asidepanel. It supports JSONPath expressions so it can change dynamically based on the HTTP request response to "source".
query
JSONPath expression to parse the HTTP response from source. The evaluation of this expression should render a list of strings or objects used as the asidepanel options content.
label
JSONPath expression used to select displaying label of the options in the asidepanel. This expression is evaluated over each list element from the "query" output.
path
JSONPath expression used to build the path that each option will redirect to upon clicking. This expression is evaluated over each list element from the "query" output.
permissions
Comma separated list of permissions associated with the path. An end user will only see the content of the asidepanel if its permissions match.
In the below 2 tabs are examples of how a static and a dynamic asidepanel look like, both in terms of XML code and UI. For simplicity, permissions and tags aren't used in these examples, so refer to the respective sections to learn more about these 2 attributes.
This XML creates a fixed content asidepanel. In this mode, the asidepanel acts similarly to a body
element, receiving section
, link
, menu
and item
, text
and divider
elements:
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu XML V2.0//EN' "-">
<tree>
<asidepanel id="static-asidepanel">
<section text="Static Internal Navigation">
<text type="bold">Static panel with links and menus to resources</text>
<link path="/app/dashboards/689619a3c9a12800114b6fbd" icon="home" label="Home"/>
<menu icon="microchip" label="Device Management">
<item path="/app/devices" label="All Devices" />
<item path="/app/device-groups" label="Device Groups" />
<item path="/app/device_types" label="Device Types" />
</menu>
<divider />
<link path="/app/settings/" icon="cog" label="Settings" />
<link path="/accounts/me/" icon="user" label="Profile" />
</section>
</asidepanel>
<body>
<section text="Main sidebar">
<link panelTarget="static-asidepanel" icon="sidebar" label="Aside static"/>
<menu defaultShow="true" icon="microchip" label="Devices">
<item panelTarget="static-asidepanel" label="Aside static"/>
<item path="/app/device-groups/" label="Group" />
<item path="/app/device_types/" label="Types" />
</menu>
</section>
</body>
</tree>
This will create a static asidepanel as follows. The options "Aside static" in the sidebar are, from top to bottom, the link
and a item
found in the body
section
.

body
Element wrapping the content of the sidebar.
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu XML V2.0//EN' "-">
<tree>
<!--Your optionals asidepanel elements go here-->
<body>
<!--Your sections and optionals home elements go here-->
</body>
</tree>
home
By default, clicking the application logo takes end-users to the dashboards module at "/app/dashboards/", usually to the last seen dashboard, nonetheless, by configuring this element, you can control the path or URL when clicking the application logo by user, using permissions and tags.
These are the attributes of the home
element:
path
Redirection path (see available paths here) or URL.
permissions
Comma separated list of permissions associated with the path. An end user will only see the effect of the home
element if its permissions match.
The example below shows 2 home
elements, each takes to a different dashboard. Note that by using tags, one is shown to User1, the other to User2 because the respective tags.
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<!-- Home for User1 with tag1 -->
<home
path="/app/dashboards/663d484aaa8d92005751b2e2"
permissions="ubi_dashboards.view_dashboardpg"
tags="tag1"/>
<!-- Home for User1 with tag2 -->
<home
path="/app/dashboards/663d484aaa8d92007364jnhd"
permissions="ubi_dashboards.view_dashboardpg"
tags="tag2"/>
<section text="Main Navigation">
<link
label="Dashboard"
path="/dashboard"
icon="home.svg"
iconFaType="classic"
iconFaStyle="solid"/>
</section>
</body>
</tree>
section
This element creates groups of menu
, link
, text
and divider
elements within the sidebar or static asidepanel. The groups are separated by an optional text label.
These are the attributes of the section
element:
text
Label/Title of the section. It can be left empty, that is text=""
permissions
Comma separated list of permissions associated with the path. An end user will only see the section if its permissions match.
Here's an XML example with 2 sections.
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<!-- First section -->
<section text="Main Section">
<link label="Dashboard" path="/dashboard" icon="home"/>
<menu label="Reports" defaultShow="true" icon="newspaper">
<menuitem label="Sales Report" path="/reports/sales"/>
<menuitem label="Inventory Report" path="/reports/inventory"/>
</menu>
</section>
<!-- Second section -->
<section text="Settings Section">
<link label="Profile" path="/settings/profile" icon="user"/>
<menu label="Admin Tools" defaultShow="false" icon="gear">
<menuitem label="User Management" path="/admin/users"/>
<menuitem label="System Logs" path="/admin/logs"/>
</menu>
</section>
</body>
</tree>

menu and item
These 2 elements help create menus within the sidebar or static asidepanel.
Attributes by element
Here's an example of a menu
and its items
.
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<section text="">
<menu
label="Reports"
defaultShow="true"
icon="chart-bar"
iconFaType="duotone"
iconFaStyle="solid">
<menuitem
label="Sales Report"
path="/app/data-analysis/reports/"
exact="true"
open="redirect"/>
<menuitem
label="Inventory Report"
path="/app/data-analysis/reports/"
exact="false"
open="tab"/>
<menuitem
label="Customers Report"
path="/app/data-analysis/reports/"
exact="false"
open="tab"/>
</menu>
</section>
</body>
</tree>

link
This element creates direct links within the sidebar or static asidepanel.
These are the attributes of the link
element:
label
Label of the menu.
panelTarget
ID of the asidepanel. If present, path is ignored.
path
Redirection path (see available paths here) or URL.
icon
Name of icon from Fontawesone.
iconFaType
Fontawesome type. [duotone | classic]
iconFaStyle
Fontawesome style. [solid | regular | light | thin]
exact
Highlights the item when in the exact path defined by path. It doesn't include the query parameters. [true | false]
open
Open link in same tab or redirect. [tab | redirect]
permissions
Comma separated list of permissions associated with the path. An end user will only see this link if its permissions match.
Here's an example of consecutive link
elements
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<section text="Main Navigation">
<link
label="Dashboards"
path="/app/dashboards/"
icon="objects-column"
iconFaType="classic"
iconFaStyle="solid"
exact="true"
open="redirect"/>
<link
label="Reports"
path="/app/data-analysis/"
icon="newspaper"
iconFaType="duotone"
iconFaStyle="regular"
exact="false"
open="tab"/>
<link
label="Settings"
path="/accounts/me/"
icon="gear"
iconFaType="classic"
iconFaStyle="light"
exact="true"
open="tab"/>
</section>
</body>
</tree>

text
Creates texts within the sidebar or static asidepanel.
These are the attributes of the text
element:
type
Type of text [h1 | h2 | h3 | h4 | normal | bold]
Here's an example of consecutive text
elements with different types
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<section text="Text Samples">
<text type="h1">This is a Heading 1</text>
<text type="h2">This is a Heading 2</text>
<text type="h3">This is a Heading 3</text>
<text type="h4">This is a Heading 4</text>
<text type="normal">This is normal body text</text>
<text type="bold">This is bold text</text>
</section>
</body>
</tree>

divider
Simply creates a horizontal line that introduces intentional separation. This element does not have any attributes
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<section text="Quick Menu">
<link label="Home" path="/app/dashboards/" icon="home" iconFaType="classic" iconFaStyle="solid"/>
<divider/>
<link label="Profile" path="/accounts/me/" icon="user" iconFaType="duotone" iconFaStyle="regular"/>
</section>
</body>
</tree>

Permissions
The elements that support the permissions attribute will only appear to those end users whose assigned permissions match those of the element configuration.
The available permissions for each possible path that's exposed to the end users in the application are:
Devices
"/app/devices/"
"ubi_datasource.view_device"
Device groups
"/app/device-groups/"
"ubi_datasource.view_devicegroup"
Dashboards
"/app/dashboards/"
"ubi_dashboards.view_dashboardpg"
Events
"/app/events/"
"ubi_events.view_eventpg"
Reports
"/app/data-analysis/"
"ubi_data_analysis.view_report"
Organizations
"/app/organizations/"
"customuser.view_organization"
Users
"/app/organizations/users"
"customuser.view_user"
Filter elements by tags
The elements that receive the "tag" attribute add a visibility layer on top of the permissions assigned to an end user. The way it works is by matching the tags of an end user with those specified in the respective element (learn more about tag filtering). Simply put, if there's at least one match between the user tags and the element's, it means the element will be visible to the user.
This filtering by tags allows customizing the sidebar based on the user accessing the platform. For example, say you want to create a direct link that takes users to their own home dashboard, you would create an XML as follows:
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V2.0//EN' "-">
<tree>
<body>
<section text="User Homes">
<!--This link creates Home for User 1-->
<link
label="Home"
path="/app/dashboards/663d484aaa8d92005751b2e2"
icon="home"
iconFaType="classic"
iconFaStyle="solid"
open="tab"
exact="true"
permissions="ubi_dashboards.view_dashboardpg"
tags="tag1"/>
<!--This link creates Home for User 2-->
<link
label="Home"
path="/app/dashboards/663d484aaa8d92007364jnhd"
icon="home"
iconFaType="classic"
iconFaStyle="solid"
open="tab"
exact="true"
permissions="ubi_dashboards.view_dashboardpg"
tags="tag2"/>
</section>
</body>
</tree>
Let's assume 2 end users, with tags "tag1" and "tag2", respectively. Note that there are 2 home links in the XML, however, since they have different tags ("tag1" and "tag2"), each home link will appear to the respective user.
Likewise, this will preview the following sidebar. We have marked what each user would see:

Last updated
Was this helpful?