Copied to clipboard

Flag this post as spam?

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


  • wolfestone 89 posts 21 karma points
    Jan 28, 2009 @ 22:03
    wolfestone
    0

    need a little help with last part of xslt syntax

    I've got this mostly figured out, I'm just stuck on what the correct sytnax is.

    I have set up a media picker in the page property, and am trying to get this to display in a template.

    I want to be able to pick one image when in the content editor, and have it display in a specific area of the page (div).

    The closest I got was retrieving the image's ID number, but I could not get it to display the image.

    my media picker is called HomeLeftImage, and I've assigned /macro/HomeLeftImage to the varible name 'url' in my xslt macro.

    This line gets my id (1065) to show up:



    And I have found this code snippet in the wiki, from which I can get the url to the image if I hard-code the id.



    I'd really appreciate any help figuring out two things:

    1. What is the syntax I need, to change the '1065' to dynamically pull the value of my xslt variable? (named 'url'). I'm guessing it involves parsing this variable to an integer, but I haven't been able to find out how to do that in xslt - I keep getting NaN as my output.

    2. Assuming this is possible, how do I then wrap this 'xsl:value-of' statement up in tags?



  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 28, 2009 @ 22:13
    Dirk De Grave
    0

    Hi wolfestone,

    1/

    [code]
    [/code]
    Be aware that this might be faulty when saving the xslt. If so (and it will), surround the statement with an xsl:if statement that checks for empty param value

    [code]
    [/code]

    or

    [code][/code]

    Hope this helps.

    Regards,
    /Dirk


  • wolfestone 89 posts 21 karma points
    Jan 28, 2009 @ 22:27
    wolfestone
    0

    Thanks Dirk, I've put in the code and am getting an xsl error:


    Error in XSLT at line 24, char 27
    22:
    23:
    24: >>> <<<
    25:

    The if/test is ok (I put just that part in first )

    The first image tag code didn't generate any html output in the browser,

    the second one causes the above xslt error.

    I really appreciate the help, if you have any suggestions as to what I might try that would be awesome.


    here is the full code of my macro, in case I'm doing the variable wrong or missing something obvious:


    [code]


    ]>

    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" exclude-result-prefixes="msxml
    umbraco.library">













    [/code]

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 28, 2009 @ 23:03
    Dirk De Grave
    0

    Hi,

    Should have verified it first.... this one should be ok

    [code]


    [/code]

    Regards,
    /Dirk

  • wolfestone 89 posts 21 karma points
    Jan 29, 2009 @ 00:27
    wolfestone
    0

    Thanks again, I'm still having trouble.

    Am I getting the media item the wrong way, by trying to use /Macro/variable?

    My media picker is a document template field, not a macro parameter, but I don't know how to access a document template field from within a macro.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 29, 2009 @ 00:39
    Dirk De Grave
    0

    Hm,

    A document template field? I assume you mean a document type property (of media picker datatype)?

    In that case $currentPage/data [@alias ='mediaPickerAlias'] should replace the $url part.

    If the media item (its id) is passed as parameters, then you should /macro/variable (or //variable) instead of /Macro/variable.

    If you're unsure how those parameters are passed to the xslt, append ?umbdebug=true to the url.

    Regards,
    /Dirk

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 29, 2009 @ 21:10
    Dan Diplo
    0

    [quote=wolfestone]My media picker is a document template field, not a macro parameter, but I don't know how to access a document template field from within a macro.[/quote]
    Hi. You surround the field with a [#....]

    So, if you have a simple macro on a page that wants to pass in the value from a document field property then you would do this:
    [code]

    [/code]
    That would then pass in the value of the property bodyText into the macro.

    See http://umbraco.org/documentation/books/macro-parameters-syntax/advanced-parameter-syntax

  • wolfestone 89 posts 21 karma points
    Jan 29, 2009 @ 21:57
    wolfestone
    0

    Thanks guys, I look forward to trying this out.

Please Sign in or register to post replies

Write your reply to:

Draft