Copied to clipboard

Flag this post as spam?

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


  • Peder Jensen 16 posts 36 karma points
    Jan 20, 2010 @ 15:11
    Peder Jensen
    0

    Opening PDF Page from image link

     

    I am new to Umbraco, and i need to open a pdf page from a image link, both the pdf and image is publish in a media picker.

    this is the code that i use now, and the picture work fine, but when you click on it, it just say that it cant find the site or page:

     

    <a href="<umbraco:Item field='Product1Link' runat='server'></umbraco:Item>">

    <umbraco:Item
      runat="server"
      field="Product1Picture"
     xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')"
    xsltDisableEscaping="true" />

    </a>

    Hope someone can help me.

  • dandrayne 1138 posts 2262 karma points
    Jan 20, 2010 @ 15:41
    dandrayne
    0

    Hi Peder

    How are you entering product1link?  If it's a link to a pdf stored in the media library you'll need to do something similar to the inline xslt you already have to display the image.  Or is it simply an upload field?

    Here's what might work if you're using the media library to store a pdf, and a mediapicker to choose it on the page

    <!-- are both these properties filled in?  We don't want to get an error -->
    <xsl:if test="string($currentPage/data [@alias='Product1Link') != '' and string($currentPage/data [@alias='Product1Picture') != '' ">
    <!-- NiceUrl on our node id (only if from a mediapicker)
    <a href="{umbraco.library:GetMedia($currentPage/data [@alias='Product1Link'])/data [@alias='umbracoFile']}">
    <img alt="Product">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='Product1Picture'])/data [@alias='umbracoFile']" />
    </xsl:attribute>
    </img>
    </a>
    </xsl:if>

    the code will differ very slightly for an upload field (no getmedia required)

    Dan

  • dandrayne 1138 posts 2262 karma points
    Jan 20, 2010 @ 15:41
    dandrayne
    0

    urgh, apologies: Incorrect comment and unclosed comment tag

  • Peder Jensen 16 posts 36 karma points
    Jan 20, 2010 @ 15:54
    Peder Jensen
    0

    So i just put this code in to my template, right ?

  • dandrayne 1138 posts 2262 karma points
    Jan 20, 2010 @ 16:35
    dandrayne
    0

    You need to create an xslt file in the developers section (right-click>create) and keep "create macro" checked.

    Then use this as the xslt 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:template match="/">

    <!-- are both these properties filled in? We don't want to get an error -->
    <xsl:if test="string($currentPage/data [@alias='Product1Link') != '' and string($currentPage/data [@alias='Product1Picture') != '' ">
    <a href="{umbraco.library:GetMedia($currentPage/data [@alias='Product1Link'])/data [@alias='umbracoFile']}">
    <img alt="Product">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='Product1Picture'])/data [@alias='umbracoFile']" />
    </xsl:attribute>
    </img>
    </a>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    Then insert the macro into your template using the insert macro button in the template editor.

    Again, this will only work if you've used a mediaPicker as your "product1link" field

    Dan

  • Peder Jensen 16 posts 36 karma points
    Jan 20, 2010 @ 16:49
    Peder Jensen
    0

    Thanks for reply and help :)

    but i get this error when i try to save the xslt fil:

    System.Xml.Xsl.XslLoadException: Expected token ']', found ')'.
    ...Page/data [@alias='Product1Link' -->)<-- != '' and string($currentPage/d... An error occurred at D:\hshome\tanjushka\pdhcestate.com\xslt\633996029159628496_temp.xslt(18,1).
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • dandrayne 1138 posts 2262 karma points
    Jan 20, 2010 @ 16:57
    dandrayne
    0

    Ahh, The dangers of just typing solutions freely, although the parser usually points out exactly what is wrong for checking.  For your own reference I did this

    string($currentPage/data [@alias='Product1Picture') != ''

    instead of

    string($currentPage/data [@alias='Product1Picture']) != ''

    (notice the missing ] )

    <?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="/">

    <!-- are both these properties filled in? We don't want to get an error -->
    <xsl:if test="string($currentPage/data [@alias='Product1Link']) != '' and string($currentPage/data [@alias='Product1Picture']) != '' ">
    <a href="{umbraco.library:GetMedia($currentPage/data [@alias='Product1Link'])/data [@alias='umbracoFile']}">
    <img alt="Product">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='Product1Picture'])/data [@alias='umbracoFile']" />
    </xsl:attribute>
    </img>
    </a>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    Dan

  • Peder Jensen 16 posts 36 karma points
    Jan 20, 2010 @ 16:58
    Peder Jensen
    0

    I found the error :)

  • Kevin 2 posts 22 karma points
    Sep 22, 2011 @ 10:43
    Kevin
    0

    Hi guys,

    I am an absolute newbie to Umbraco, and my problem is similar to the one discribed here. I have a picture called "card1.png" and want this picture to be a link to a pdf file called "card1.pdf". I am displaying the picture card1.png with the media picker, the property is called pic (alias: pic). I have tried to use the code here for my XSLT file and inserted the matching macro in my template, but nothing really happens. Can anyone help? I am using the 4.7.0 Version by the way.

    Greets

Please Sign in or register to post replies

Write your reply to:

Draft