Copied to clipboard

Flag this post as spam?

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


  • F 19 posts 39 karma points
    Aug 02, 2011 @ 10:20
    F
    0

    Problem understanding and using "$currentPage"

    Hello,

    I have the folowing structure for my website :

    +Home
    +Blog1
    +Post1
    +Post2
    +Blog2
    +Post1
    +Post2
    +Page1

    On Page1 I'm trying to retrieve informations about Blog1 and blog2, but here is a strange thing :

    $currentPage/@level gets me "2", which is normal (level 2 page)

    BUT 

    $currentPage/ancestor-or-self, or $currentPage/parent, or even $currentPage/self get me nothing.

    Is there anything I'm doing wrong?

    Thank you,

    F

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 02, 2011 @ 10:35
    Fuji Kusaka
    0

    Hi there,

     

    Basically the currentPage variable contains all the xml from node where your XSLT is being executed and its child elements  such as when you make use of ancestors etc.

    I think this might work for you though

    <xsl:value-of select="$currentPage/parent::node/data[@alias=information]" />
  • F 19 posts 39 karma points
    Aug 02, 2011 @ 12:17
    F
    0

    Hello,

    thank you for your email, the code you gave me doesn't work for me, but at least, i got some understanding of what info is in "currentPage".

    I believe either there's something wrong in my code, or maybe the way my nodes are configured? Maybe I miss a reserence or something?

    Anyway, here is my code (sorry, I don't know the tags to separate the code from the rest of the post) :

     EDIT : any code I post is unreadable, what tags should I use? I tried [code][/code]

    Thank you for your help,

    F

    EDIT : this seems to work : 

    Now i'm glad I got it to work, but this is mere copy/paste from the siteMap macro. Can anyone take some time to explain a newbie why this syntax works and not the others I used?

    Thanks,

    F

  • praveity 100 posts 125 karma points
    Aug 04, 2011 @ 14:07
    praveity
    0

    Hi F (unique name) :)

    I am considering you are using, umbraco version above 4.5 (which uses new schema) and Page1 and Blog1 are different doc type.

    Replace the BlogDocTypeAliasName with the actual blog doc-type alias name..

    <xsl:for-each select="$currentPage/ancestor-or-self::BlogDocTypeAliasName[@isDoc and @level = 2]">

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

    </xsl:for-each>

  • F 19 posts 39 karma points
    Aug 09, 2011 @ 10:56
    F
    0

    Thanks, 

    That works well, and helped me understand how to getto blogPost, or any other type of content for that matter.

    Thanks again,
    F. 

Please Sign in or register to post replies

Write your reply to:

Draft