Copied to clipboard

Flag this post as spam?

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


  • Bogice 6 posts 27 karma points
    May 23, 2011 @ 18:19
    Bogice
    0

    Access page field value

    Hi, 

    I ve tried to access a page field's value from xslt but seem not successful. Im using new schema 4.5.2, the page field named Top Title, alias:topTitle and here is the xslt:

    <?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" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:value-of select ="$currentPage" disable-output-escaping="yes" />
      <xsl:value-of select="$currentPage/data [@alias = 'topTitle']" disable-output-escaping="yes" />
      
    </xsl:template>

    </xsl:stylesheet>

    The first xsl:value of is able to pull the all fields' value, but not the second with the specific topTitle name. Am i missing something here?

    PS: i did put this marco on the master page with form runat = server tag. Is that make problem?

    Thank you


  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 23, 2011 @ 18:29
    Dennis Aaen
    0

    Hi Ahn

    You are using Umbraco version 4.5.2

    And with this version there comes a new XML schema.  And in your code you are write xslt using the old XML schema. The fact is that from version 4.5 uses the new XML schema.

    So you can try something like:

     <xsl:value-of select="$currentPage/topTitle" disable-output-escaping="yes" />

    This will hopefully help you.

    /Dennis

  • Bogice 6 posts 27 karma points
    May 23, 2011 @ 18:34
    Bogice
    0

    Thank you Dennis, it WORKS.

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 23, 2011 @ 19:04
    Dennis Aaen
    0

    I am glad to hear that Bogice.

    But if you're more comfortable to work with the old XML schema, it is of course also possible to switch to the old XML schema if you are using version 4.5.2 of Umbraco

    This can be done by following this guide:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/switching-between-old-and-new-schema

    Or you can read about the new XML schema here:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema.

    Another alternative could be the Umbraco videos about the new schema on umbraco.tv if you have access to this.

    http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals

    But I'm glad I could help you
    /Dennis

  • Bogice 6 posts 27 karma points
    May 23, 2011 @ 20:45
    Bogice
    0

    Thanks Dennis for those links and promply response, I will use a new schema syntax as documented. Just out of curious, how can i mark this thread as answered, so ppl can know.

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 23, 2011 @ 20:53
    Dennis Aaen
    0

    I think you can mark this post as solved by running your mouse over where you can give high five.
    If I remember correctly, but as I said, I'm not quite sure. :)

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft