Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee 95 posts 115 karma points
    Nov 23, 2013 @ 14:55
    Lee
    0

    access property

    Hi

    I haven't worked in Umbraco for a long time, but I have forgotten how to access a property of a node. So I have a node set up with the property 'hideHospitalNumber' attached.

    I am using the code below to test if the 'hideHospitalNumber value but it is 0 or 1.

    Could someone please take a look?

     

    Many thanks

     

     

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>

    <xsl:stylesheet 

    version="1.0" 

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 

    xmlns:msxml="urn:schemas-microsoft-com:xslt"

    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 

    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

     

     

    <xsl:output method="xml" omit-xml-declaration="yes"/>

     

    <xsl:param name="currentPage"/>

    <xsl:variable name="source" select="$currentPage/serviceContentSource"/>

    <xsl:template match="/">

    <xsl:value-of select="$currentPage"/>

    <xsl:choose>

    <xsl:when test="$currentPage/serviceContentSource != ''">

    <div class="tel">

    <ul>

    <xsl:if test="umbraco.library:GetXmlNodeById($source)/hideHospitalNumber = '0'">

    <li><a href=""><b>Hospital and Referrals</b><br/>Tel: +44 (0)1638 782020<br/>referrals@neh.uk.com</a></li>

    </xsl:if>

    <xsl:if test="umbraco.library:GetXmlNodeById($source)/hideEquineNumber = '0'">

    <li><a href="£"><b>Equine Practice</b><br/>Tel: +44 (0)1638 782000<br/>office@neh.uk.com</a></li>

    </xsl:if>

    <xsl:if test="umbraco.library:GetXmlNodeById($source)/hideLabNumber = '0'">

    <li><a href="£"><b>Lab</b><br/>Tel: +44 (0)1638 782050<br/>lab@neh.uk.com</a></li>

    </xsl:if>

    </ul>

    </div>

    </xsl:when>

    <xsl:otherwise>

     

    <div class="tel">

    <ul>

    <xsl:if test="$currentPage/hideHospitalNumber = '0'">

    <li><a href=""><b>Hospital and Referrals</b><br/>Tel: +44 (0)1638 782020<br/>referrals@neh.uk.com</a></li>

    </xsl:if>

    <xsl:if test="$currentPage/hideEquineNumber = '0'">

    <li><a href="£"><b>Equine Practice</b><br/>Tel: +44 (0)1638 782000<br/>office@neh.uk.com</a></li>

    </xsl:if>

    <xsl:if test="$currentPage/hideLabNumber = '0'">

    <li><a href="£"><b>Lab</b><br/>Tel: +44 (0)1638 782050<br/>lab@neh.uk.com</a></li>

    </xsl:if>

    </ul>

    </div>

    </xsl:otherwise>

    </xsl:choose>

    </xsl:template>

    </xsl:stylesheet>

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 23, 2013 @ 15:14
    Chriztian Steinmeier
    0

    Hi Lee,

    Here's a condensed version without the duplication - see if you can figure out how it works — otherwise, feel free to ask about it:

    <xsl:variable name="source" select="$currentPage/serviceContentSource" />
    
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="normalize-space($source)">
                <xsl:apply-templates select="umbraco.library:GetXmlNodeById($source)" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="$currentPage" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <!-- Generic template for a Document node -->
    <xsl:template match="*[@isDoc]">
        <div class="tel">
            <ul>
                <xsl:if test="not(hideHospitalNumber = 1)">
                    <li><a href=""><b>Hospital and Referrals</b><br/>Tel: +44 (0)1638 782020<br/>referrals@neh.uk.com</a></li>
                </xsl:if>
                <xsl:if test="not(hideEquineNumber = 1)">
                    <li><a href="£"><b>Equine Practice</b><br/>Tel: +44 (0)1638 782000<br/>office@neh.uk.com</a></li>
                </xsl:if>
                <xsl:if test="not(hideLabNumber = 1)">
                    <li><a href="£"><b>Lab</b><br/>Tel: +44 (0)1638 782050<br/>lab@neh.uk.com</a></li>
                </xsl:if>
            </ul>
        </div>
    </xsl:template>
    

    /Chriztian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies