General Node Trees - Eonic/ProteanCMS GitHub Wiki
This document provides an overview of various general node trees used within ProteanCMS, including how to retrieve and manipulate data from the XML structure.
To access the main page element:
<xsl:variable name="page" select="/Page"/>
This variable stores the root <Page>
node, which serves as the primary context for further data extraction.
To retrieve the unique identifier for the page:
<xsl:variable name="pageId" select="/Page/@id"/>
This variable captures the id
attribute of the <Page>
node, which can be used for referencing or conditional logic.
To extract the article ID from the query string:
<xsl:variable name="artId" select="number(concat(0,/Page/Request/QueryString/Item[@name='artid']))"/>
This variable converts the artid
query string parameter to a number, ensuring it can be used for numeric operations.
To define the application path based on server variables:
<xsl:variable name="appPath">
<xsl:choose>
<xsl:when test="/Page/Request/ServerVariables/Item[@name='APPLICATION_ROOT']/node()!=''">
<xsl:value-of select="/Page/Request/ServerVariables/Item[@name='APPLICATION_ROOT']/node()"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>/</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
This variable checks for an application root path in server variables and sets it, defaulting to the root /
if not found.
To access the menu structure:
<xsl:variable name="menu" select="/Page/Menu"/>
This variable references the <Menu>
node, which contains all navigational items for the site.
To retrieve the shopping cart details:
<xsl:variable name="cart" select="/Page/Cart"/>
This variable stores the <Cart>
node, allowing access to cart-related data.
To determine if the current page is a cart order page:
<xsl:variable name="cartPage" select="/Page/Cart[@type='order']/Order/@cmd!=''"/>
This variable checks if the cart type is 'order' and whether a command exists, indicating an active cart page.
To check if the page is in admin mode:
<xsl:variable name="adminMode" select="/Page/@adminMode"/>
This variable retrieves the adminMode
attribute, which can be used to enable or disable certain features in the CMS.
To find the current page in the menu:
<xsl:variable name="currentPage" select="/Page/Menu/descendant-or-self::MenuItem[@id=/Page/@id]"/>
This variable locates the <MenuItem>
that matches the current page's id
, enabling specific menu item highlighting.
To access different levels of menu items in sections:
<xsl:variable name="sectionPage" select="/Page/Menu/MenuItem/MenuItem[descendant-or-self::MenuItem[@id=/Page/@id]]"/>
<xsl:variable name="subSectionPage" select="/Page/Menu/MenuItem/MenuItem/MenuItem[descendant-or-self::MenuItem[@id=/Page/@id]]"/>
<xsl:variable name="subSubSectionPage" select="/Page/Menu/MenuItem/MenuItem/MenuItem/MenuItem[descendant-or-self::MenuItem[@id=/Page/@id]]"/>
<xsl:variable name="subSubSubSectionPage" select="/Page/Menu/MenuItem/MenuItem/MenuItem/MenuItem/MenuItem[descendant-or-self::MenuItem[@id=/Page/@id]]"/>
<xsl:variable name="subSubSubSubSectionPage" select="/Page/Menu/MenuItem/MenuItem/MenuItem/MenuItem/MenuItem/MenuItem[descendant-or-self::MenuItem[@id=/Page/@id]]"/>
These variables provide access to various hierarchical levels of menu items, enabling more granular control over navigation.
To define the match height type for layout purposes:
<xsl:variable name="MatchHeightType" select="'matchHeight'"/>
This variable sets a constant value for layout configurations that require equal height elements.
To specify gutter widths for layout spacing:
<xsl:variable name="GutterWidth" select="'20'"/>
<xsl:variable name="GutterWidthLg" select="'30'"/>
These variables define gutter widths for responsive design, ensuring consistent spacing between elements.
To control responsive image settings:
<xsl:variable name="responsiveImageSizes">off</xsl:variable>
This variable allows for the toggling of responsive image size adjustments, optimizing image loading based on screen size.
To construct the base URL of the site:
<xsl:variable name="siteURL">
<xsl:variable name="baseUrl">
<xsl:call-template name="getXmlSettings">
<xsl:with-param name="sectionName" select="'web'"/>
<xsl:with-param name="valueName" select="'BaseUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="cartSiteUrl">
<xsl:call-template name="getXmlSettings">
<xsl:with-param name="sectionName" select="'cart'"/>
<xsl:with-param name="valueName" select="'SiteURL'"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$cartSiteUrl!=''">
<xsl:value-of select="$cartSiteUrl"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$baseUrl!=''">
<xsl:value-of select="$baseUrl"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/Page/Request/ServerVariables/Item[@name='SERVER_NAME']"/>
<xsl:if test="/Page/Request/ServerVariables/Item[@name='SERVER_PORT'] != '80' and /Page/Request/ServerVariables/Item[@name='SERVER_PORT'] != '443'">
<xsl:text>:</xsl:text>
<xsl:value-of select="/Page/Request/ServerVariables/Item[@name='SERVER_PORT']"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
This variable constructs the full site URL, considering both base URLs and potential cart-specific URLs, handling different server ports appropriately.
To derive the site name based on server settings:
<xsl:variable name="sitename">
<xsl:choose>
<xsl:when test="$siteURL=''">
<xsl:text>http</xsl:text>
<xsl:if test="$page/Request/ServerVariables/Item[@name='HTTPS']='on'">s</xsl:if>
<xsl:text>://</xsl:text>
<xsl:value-of select="$page/Request/ServerVariables/Item[@name='SERVER_NAME']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$siteURL"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
This variable constructs the site name by checking whether a site URL is defined and including the appropriate protocol based on HTTPS status.
To determine the correct href for navigation:
<xsl:variable name="href">
<xsl:choose>
<xsl:when test="/Page/ContentDetail">
<xsl:apply-templates select="/Page/ContentDetail/Content" mode="getHref"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$currentPage" mode="getHref"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
This variable evaluates whether the current page has content details and applies the appropriate templates to retrieve the corresponding href.
To define the version of the script being used:
<xsl:variable name="scriptVersion" select="'2'"/>
This variable sets the script version number, which can be useful for compatibility checks and version control.
To extract the command from the query string:
<xsl:variable name="ewCmd" select="/Page/Request/QueryString/Item[@name='ewCmd']/node()"/>
This variable captures the ewCmd
parameter from the query string, which may dictate the action to be taken by the application.