Copied to clipboard

Flag this post as spam?

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


  • Bent Holz 100 posts 273 karma points
    Nov 17, 2013 @ 14:24
    Bent Holz
    0

    Inline Xslt Media Picker ID to URL

    Been searching for a solution in the forum, but can't get any of it to work or i'm simply doing it wrong...

    Running Umbraco 4.9, I now have a page that displays all subpages and some of their content via Xslt - no problem!

    Now I just wanna make a page, that displays the full details of one of the subpages, when you click on a link. So I have created a template, that pulls out all the fields I need from my documenttype and all is dandy, but...

    I have set up a media picker value "pdfFile" and when I pull the value into the template, I get the ID. The trick is to make this value into a link, so that you can view/download the selected pdf, but I can't figure out how to make the link...

    I've tried several inline approaches, but no luck. Is this not possible or do I need to make a specific macro for this value and how would that look like?

    Help me Obi Wan Kenobi... 

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 17, 2013 @ 22:05
    Chriztian Steinmeier
    0

    Hi Crawn,

    It's possible to do as an "inline XSLT" thing, but it will be much more flexible as a separate macro. That said, here's the way to do it:

    <umbraco:Item field="pdfFile" xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile" insertTextBefore="&lt;a href=&quot;" insertTextAfter="&quot;&gt;Download PDF&lt;/a&gt;" runat="server" />
    

    /Chriztian

  • Bent Holz 100 posts 273 karma points
    Nov 18, 2013 @ 11:15
    Bent Holz
    0

    Hi Chriztian... and thx for your answer!

    I found those lines in another post and when i added it to my template, nothing renders out... :(

    Cheers Crawn

     

     

  • Bent Holz 100 posts 273 karma points
    Nov 21, 2013 @ 14:06
    Bent Holz
    0

    Hi again Chriztian...

    Are you sure this is correct:

    xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile"

    the {0}, 0 does not ring a bell to me

    Cheers

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 21, 2013 @ 14:22
    Dennis Aaen
    0

    Hi Crawn,

    Have you tried this one.

    <umbraco:Itemfield="pdfFile"xslt="umbraco.library:GetMedia({0}, true)/umbracoFile"insertTextBefore="&lt;a href=&quot;"insertTextAfter="&quot;&gt;Download PDF&lt;/a&gt;"runat="server"/>

    My inspiration is Chriztian´s post, and this documentation here: http://our.umbraco.org/wiki/reference/templates/umbracoitem-element/inline-xslt

    Or alternatively you could try this one:

    <a href="<umbraco:Itemfield='pdfFile'xslt='umbraco.library:GetMedia({0},true())/umbracoFile'xsltDisableEscaping='true'runat='server'/>">Download PDF</a>

     

    Hope this helps,

    /Dennis

  • Bent Holz 100 posts 273 karma points
    Nov 21, 2013 @ 14:42
    Bent Holz
    0

    Hi Dennis...

    Thx for your time...

    Pasted both codes and both just produce a runtime error...

    Read the documentation over 3 times to get it to render out anything... no luck... i'm prolly doing something very wrong, but i can't see what.

    Thx for helping...

     

    /Crawn

     

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 21, 2013 @ 14:48
    Chriztian Steinmeier
    0

    Hi Crawn,

    Yes - should be correct; the GetMedia() method take an ID and a boolean - the {0} gets replaced with the field's contents (which should be the media ID as you've mentioned before) - the last zero is equivalent to a boolean false() (we're inside XSLT at this point) which means we don't want any child nodes that PDF file may have.

    Maybe the upload field/property for the File isn't named umbracoFile? (That's the standard, but it could have been named otherwise for some reason).

    /Chriztian

  • Bent Holz 100 posts 273 karma points
    Nov 21, 2013 @ 14:58
    Bent Holz
    0

    Hi again Chriztian... and Dennis...

    Trying to debug this i put the following into my template:

     <umbraco:Item runat="server" field="opstaldfoder" />

    Renders out id, in this case "1433"

     <umbraco:Item runat="server" field="opstaldfoder" xslt="umbraco.library:GetMedia({0}, true())/umbracoFile" />

    Renders out nothing...

    If i go into "settings / media types / file" i have "umbracoFile" if thats what you mean Chriztian?
    /Crawn
     
  • Claushingebjerg 939 posts 2574 karma points
    Nov 22, 2013 @ 15:45
    Claushingebjerg
    0

    Its beacause its a horse site ;) they never work right :)

  • Claushingebjerg 939 posts 2574 karma points
    Nov 22, 2013 @ 15:55
    Claushingebjerg
    100
    <umbraco:Item field="opstaldfoder" xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile" insertTextBefore="&lt;a href=&quot;" insertTextAfter="&quot;&gt;Download PDF&lt;/a&gt;" runat="server" />
    
    Works like a charm
Please Sign in or register to post replies

Write your reply to:

Draft