Copied to clipboard

Flag this post as spam?

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


  • Roger Sutton 52 posts 124 karma points
    Dec 13, 2010 @ 18:23
    Roger Sutton
    0

    Reading child page data from Home page

    Hi,

    Sorry but a complete newbie to Umbraco and xslt. I have a number of pages which sit under the Home page and some of these (Sale pages) also have descendants. I want to present a date (called auction date) from the first one of these on the home page. The following code works fine to get the child page title but I can't see how to reference the in page data.

    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="2"/>
    <xsl:variable name="pageRoot" select="$currentPage/Sale [@nodeName='Auctions']" />

    <xsl:template match="/">
      
    <xsl:for-each select="$pageRoot/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <xsl:if test="position()=1">
        <h2>
          <xsl:value-of select="umbraco.library:FormatDateTime(./data[@alias='auctionDate'], 'ddd d MMM yyyy')"/>
        </h2>
      </xsl:if>
    </xsl:for-each>

    </xsl:template>

    What do I actually need in the 'value-of' statement?

    Sorry to be thick but I'm waiting for my xslt book to arrive but I'm still getting pressure to make things work.

    Thanks

     

  • Dan 1288 posts 3921 karma points c-trib
    Dec 13, 2010 @ 18:40
    Dan
    0

    Hi Roger,

    There should be a button in the top of your XSLT editor for inserting 'value-of' items.  Click this and you should see a drop-down of pre-values.  Select one of these and 'insert' and it should build the XSLT for you.

    Assuming your code above is really doing what you want it to apart from bringing the page data in, your XSLT for that will be very simple.  Something like:

    <xsl:value-of select="column1"/>

    Where 'column1' is the alias of the content property on your doctype.

    HTH

  • Roger Sutton 52 posts 124 karma points
    Dec 13, 2010 @ 18:44
    Roger Sutton
    0

    You are absolutely spot on, thank you. I've got bound up reading fragments of xsly syntax in the wiki and didn't even look in those buttons.

    thanks again

  • Rich Green 2246 posts 4008 karma points
    Dec 13, 2010 @ 18:45
    Rich Green
    0

    Hi Roger,

    Firstly, welcome to the forum!

    Hope I can help you out.

    To get reference to a property on the home page you can use this (Umbraco version >= 4.5)

    <xsl:value-of select="$currentPage/ancestor-or-self::root/node/Auctions"/>

    The XML schema of Umbraco changed recently at version 4.5, it seems like you are mixing up these schemas, some differences are outlined here http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias

    It's really useful to view the XML that Umbraco has for the published data, this file is named umbraco.config and is held in the App_Data directory (4.5 and upwards)

    Rich

  • Rich Green 2246 posts 4008 karma points
    Dec 13, 2010 @ 18:47
    Rich Green
    0

    I was a little late on the button, hope my posts helps you somewhat any how.

    Rich

  • Roger Sutton 52 posts 124 karma points
    Dec 13, 2010 @ 18:48
    Roger Sutton
    0

    Thanks Rich, I'll also change my select syntax as well. :-)

Please Sign in or register to post replies

Write your reply to:

Draft