Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    Jun 25, 2012 @ 00:05
    René
    0

    Select media from subpage

    Hi 

    I have been trying all day to get this working, now i need a little help.

    Umbraco version: umbraco v 4.7.2 

    I have this site structure

    Page 1
    --Page 2
    ----Page 3

    On page 3 i have a mediaPicker witch i need to use to show a image on page 2. There are several Nodes on the same level as page 3. all with a mediaPicker to show different images.

    I have got it to to work with a mediaPicker on page 2, but it of cource shovs the same image 20 times.

    Instead of the $Currentnode i need to select the media picker from the subpage.

    Here is the xslt

    <xsl:if test="normalize-space($currentPage/mediaPicker)"
                     <href="{umbraco.library:NiceUrl($currentPage/mediaPicker)}" class="preloader" rel="prettyPhoto">
             
                        <xsl:variable name="imageId" select="$currentPage/mediaPicker" />
                        <xsl:if test="normalize-space($imageId)">
                            <xsl:variable name="image" select="umbraco.library:GetMedia($imageId, false())" />
                        <img src="{$image/umbracoFile}" rel="prettyPhoto" />
                      </xsl:if>
                    </a
                  </xsl:if>  

     

    Here is what i need as output

    <!--<a href="/images/img/fproject_4_1.jpg" class="preloader" rel="prettyPhoto" title="" ><img src="/images/img/fproject_4_1.jpg" alt="" rel="prettyPhoto" /></a>-->
    

     

    Here is the entitre 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" 
      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:template match="/">
      
      <!-- The fun starts here -->

        <section class="portfolio_container four_blocks">
            <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
              <article class="portfolio">
                <figure>
                  <xsl:if test="normalize-space($currentPage/mediaPicker)"
                     <href="{umbraco.library:NiceUrl($currentPage/mediaPicker)}" class="preloader" rel="prettyPhoto">
             
                        <xsl:variable name="imageId" select="$currentPage/mediaPicker" />
                        <xsl:if test="normalize-space($imageId)">
                            <xsl:variable name="image" select="umbraco.library:GetMedia($imageId, false())" />
                        <img src="{$image/umbracoFile}" rel="prettyPhoto" />
                      </xsl:if>
                    </a
                  </xsl:if>  
                 <!--<a href="/images/img/fproject_4_1.jpg" class="preloader" rel="prettyPhoto" title="" ><img src="/images/img/fproject_4_1.jpg" alt="" rel="prettyPhoto" /></a>-->
                </figure>
            <header class="entry-header">
              <h5 class="entry-title"><href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
                </a>
              </h5>
            </header>
            <footer class="entry-meta">
              <div class="post_category">
                <href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="tags1"/></a><href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="tags2"/></a>
              </div>
            </footer>
            <div class="entry-content">
              <class="button" href="{umbraco.library:NiceUrl(@id)}">
                <span><xsl:value-of select="@nodeName"/></span>
                </a>
            </div>
            </article>
          </xsl:for-each>
        </section>

      </xsl:template>
    </xsl:stylesheet>

     

    Tanks in advance, thumbs up for our.umbraco

    René

     

     


  • Paul Blair 466 posts 731 karma points
    Jun 25, 2012 @ 00:43
    Paul Blair
    0

    Try

    <xsl:if test="normalize-space(./mediaPicker)"> 
                     <a href="{umbraco.library:NiceUrl(./mediaPicker)}" class="preloader" rel="prettyPhoto">
             
                        <xsl:variable name="imageId" select="./mediaPicker" />
                        <xsl:if test="normalize-space($imageId)">
                            <xsl:variable name="image" select="umbraco.library:GetMedia($imageId, false())" />
                            <img src="{$image/umbracoFile}" rel="prettyPhoto" />
                        </xsl:if>
                    </a> 
                  </xsl:if>  

    This will reference the node within the for loop rather than the current page

  • René 327 posts 852 karma points
    Jun 25, 2012 @ 01:02
    René
    0

    Tanks Paul, saved my day.

    And it was so simple... 

  • 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