Copied to clipboard

Flag this post as spam?

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


  • vaibhav 119 posts 139 karma points
    May 26, 2011 @ 16:34
    vaibhav
    0

    Help with media picker

    Hi,

    I have one Media Picker in the document type ..... i will select one pdf file using that media picker which is there in the media library..... i want to open that file in new windows using xslt ....how to do that ?

    I did tried this

    <a target="_blank" href="{pubSelectfile}"> >> </a>

    but some how it is not working for me ....

    what to do ?

  • bob baty-barr 1180 posts 1294 karma points MVP
    May 26, 2011 @ 20:40
    bob baty-barr
    1

    you will need to have an xslt macro or inline xslt to get the media item link [umbracoFile]

    here is a snippet tht should point you in the right direction... this snippet actually lists a folder of documents from media...

    <xsl:if test="relatedDocumentsList !=''">
          <h4>Related Documents</h4>
          <ul id="relatedContent">
            <xsl:variable name="docList" select="umbraco.library:GetMedia(relatedDocumentsList,true())"/>
            <xsl:for-each select="$docList/File">
              <li><a href="{umbracoFile}" target="_blank"><xsl:value-of select="@nodeName"/></a></li>
            </xsl:for-each>
          </ul>
      </xsl:if>

    if you only need to list one... it would be modified like this..

    <xsl:if test="relatedDocumentsList !=''">
      <h4>Related Document</h4>
      <xsl:variable name="docList" select="umbraco.library:GetMedia(relatedDocumentsList,false())"/>
              <p><a href="{$docList/umbracoFile}" target="_blank"><xsl:value-of select="@nodeName"/></a></p>
    </xsl:if>

    Basically... relatedDocumentsList is the media picker property alias on your docType... we check to make sure it has a value... then we do something with it. Hope that helps.

  • vaibhav 119 posts 139 karma points
    May 27, 2011 @ 07:58
    vaibhav
    0

    Hi

    I dident understood what you did in this code...but its not working for me ....

    I have one media picker (alias name : pubSelectfiles ) .... i will choose one file (lets say i will choose pdf file) form media library using that media picker....

    I want to open that selected file in new windows using xslt .....how to do that?

  • Pasang Tamang 258 posts 458 karma points
    May 27, 2011 @ 12:15
    Pasang Tamang
    0

    Hi vaibhav

    From bob's example just remove relatedDocumentsList by your alias name pubSelectfiles. Then it should works as you want.

    Thanks

    Pnima

     

  • vaibhav 119 posts 139 karma points
    May 30, 2011 @ 14:42
    vaibhav
    0

    Hi,

    I still cant understood it....Here is my code ...can u help to put that in this

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


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
        <xsl:for-each select="$currentPage/*[@isDoc and string(umbracoNaviHide) != '1']">
          <br/>
       <div id="pubSection">
         <div id="pubSectionHeader">
         <xsl:value-of select="@nodeName"/>
         </div>
          <xsl:for-each select="././*[@isDoc]">
            <div id="pubArticle">
              <div id="pubImage"><img src="{./pubThumbnail}" alt="" width="115px" height="90px"/></div>
              <div id="pubContentArea">
              <div id="pubHeader"><xsl:value-of select="pubHeader"/></div>
              <div id="pubContent"><xsl:value-of select="umbraco.library:TruncateString(umbraco.library:ReplaceLineBreaks(pubContent),190,'')"/>
                <xsl:if test="string-length(umbraco.library:ReplaceLineBreaks(pubContent) &gt; 65)">  <!-- only show the link if truncated? -->
                 
    <!-- Here i want to show the link from where that file will open in new window -->
             
     
    </xsl:if>
                </div>
              </div>

            </div>
             </xsl:for-each>
           </div>
         </xsl:for-each>    
    </xsl:template>

    </xsl:stylesheet>
  • vaibhav 119 posts 139 karma points
    May 31, 2011 @ 09:31
    vaibhav
    0

    There is no one who can help me ?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 18, 2011 @ 21:14
    Fuji Kusaka
    0

    Hi there you could try something like that if you want to use a macro

    <xsl:for-eachselect="$currentPage">

    <
    xsl:iftest="pubSelectfile !=''">
      <h4>Related Document</h4>
    <a>
    <xsl:attribute name="href">
    <xsl:value-of select="pubSelectfile" /> 
    </xsl:attribute>
    <xsl:value-of select="@nodeName"/>
    </a> 
    </xsl:if>
    </xsl:for-each> 

     

Please Sign in or register to post replies

Write your reply to:

Draft