Copied to clipboard

Flag this post as spam?

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


  • Evan 344 posts 99 karma points
    Aug 26, 2009 @ 21:24
    Evan
    0

    Need some quick help, having a child node see the parent node media ID...

    I have set up some jQuery using innerfade and have it working great on the parent pages, I would like the child pages to inherit it.  I have set up the xslt as follows....

    [code]

    <?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="MediaRootId" select="$currentPage/data [@alias = 'MediaRoot']"/>
    <xsl:template match="/">

    <!-- start writing XSLT -->

    <xsl:if test="$MediaRootId != '' ">
            <!-- just added as cast-workaround -->
    <ul id="rotate">
            <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/node">

                    <li>
                        <xsl:if test="@nodeTypeAlias='Image'">
                          <xsl:element name="img">
                            <xsl:attribute name="src">
                              <xsl:value-of select="data [@alias = 'umbracoFile']"/>
                            </xsl:attribute>
                          </xsl:element>
                         
                         
                        
                        </xsl:if>
                  </li>


            </xsl:for-each>
    </ul>
          </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

    [/code]

     

    I thought that I had to change the [code]<xsl:variable name="MediaRootId" select="$currentPage/data [@alias = 'MediaRoot']"/>[/code] line to allow ancestors-and-self, but that does not seem to make any difference, what am i missing?

  • Evan 344 posts 99 karma points
    Aug 26, 2009 @ 21:24
    Evan
    0

    wow that did not work at all.... here it is...

     

    <?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="MediaRootId" select="$currentPage/data [@alias = 'MediaRoot']"/>
    <xsl:template match="/">

    <!-- start writing XSLT -->

    <xsl:if test="$MediaRootId != '' ">
            <!-- just added as cast-workaround -->
    <ul id="rotate">
            <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/node">

                    <li>
                        <xsl:if test="@nodeTypeAlias='Image'">
                          <xsl:element name="img">
                            <xsl:attribute name="src">
                              <xsl:value-of select="data [@alias = 'umbracoFile']"/>
                            </xsl:attribute>
                          </xsl:element>
                         
                         
                        
                        </xsl:if>
                  </li>

                <!-- Add other <td> entries here to display further info -->

            </xsl:for-each>
    </ul>
          </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 26, 2009 @ 21:57
    Thomas Höhler
    1

    As I understand you you have a content hierachy where a node has a media picker to select a media folder. On the subpages you also want to show the images selected by the media picker of the ancestor node.

    If so and the content node with the media picker is on a defined level just do something like this:

    <xsl:variable name="MediaRootId" select="$currentPage/ancestor-or-self::node [@level = 2]/data [@alias = 'MediaRoot']"/>

    Or if the content node with the media picker has a defined nodeTypeAlias just do:

    <xsl:variable name="MediaRootId" select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'NODETYPEALIAS']/data [@alias = 'MediaRoot']"/

    You have to select the node with media picker via ancestor-or-self::node and some filtering to select the exakt node

    hth,
    Thomas

Please Sign in or register to post replies

Write your reply to:

Draft