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?
[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
[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.
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?
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
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]
Hi,
Should have verified it first.... this one should be ok
[code]
[/code]
Regards,
/Dirk
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.
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
[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
Thanks guys, I look forward to trying this out.
is working on a reply...