I'vre read numerous topics on the forum regarding 4.5 schema image reference with GetMedia, but i can't get it to work, even when setting a variable first. Any suggestions?
I'm a bit confused about how there can be so many different suggestion to the same "little" problem. Is there somewhere i can pick up a book or another type of reference, that'll teach me correct xslt for the new schema?
Again thanks a bunch for all your help and inputs!
I think the reason why there can be some confusion about the GetMedia-extension and path to the images is because of a bug in v4.5 where you needed toreference the root element of the media-element as well. If you take a look a Dirks answer and the first snippet that Niels provided you'll see that they both suggested an extra /Image to the path. Theese solutions will work if you had used v4.5, because of the bug.
But the bug has been fixed i v4.5.1 so that's why we don't need to use the extra /Image in the expression.
A good idea is to check how the XML looks by writing it out in a textarea. Like this:
You can do the same with $currentPage to see the XML on the current page, variables etc.. I think it's a good way of checking if we are writing the right XSLT. Does that make sense at all? :D
Har også kigget efter samme løsning og læste en del forslag som jeg prøver af. Sidder med 4.2 og har haft syntax problemer. Mener, den Kim nævner ovenpå fungerer... indtil videre... så længe så godt.
I hvert fald parser den i XSLT Visualizer. Kan få et fint file path, også et billedvisning ligefrem. Desværre bliver der returneret en nodeId i browseren.
Har en xslt-fil, macro med kald fra Master template. Har oprettet media picker på doctypen, som ligger øverste i hierarkien (forsiden). Vil gerne oprette en banner, som kan skiftes af brugeren/administratoren vha media picker. Nu er der to ting, der skal løses:
1. Billedet skal selvfølgelig vises fremfor nodeID. 2. Hvordan kan jeg få alle children til at vise samme banner (globalt), uden at jeg skal oprette en media picker på alle doctyper?
Hey Kim. I'm new to the forum, and it didn't register I was writing in Danish until you answered. English is my native language, even. Crazy., ;~)
Okay, here's the short and skinny. I've been trying to run the XSLT after your suggestion. Am I missing something else in the XSLT file or will this stand alone when grabbing, setting and rendering a pic from the Media Picker?
... also, Kim, I've even inserted the textarea you mentioned as a developmental curiosity. I get it to render in the Visualizer but absolutely nothing shows in the browser. I'm wondering if it isn't something I've missed in the DEV process, but the fact that the browser shows an ID puzzles me. The macro must be passing something to the template.
When you say that you are running on an Umbraco version 4.2 are you then meaning v4.0.2 or 4.5.2? As far as I know there has never been a 4.2 and the XML schema has changed in v4.5 (and the media XML actually again in 4.5.1).
Is it this code that renders the id in the browser:
<xsl:value-ofselect="$currentPage/topBanner"/>
When you used the textarea, did you then see it on a page where there was an image selected in the topBanner-field?
Yeah, that was a boner on my part - I meant 4.5.2. Latest version.
Something
else is obviously wrong. The text area does not appear to be reaching
the browser - it is not visible in the source code at all. Any ideas?
The XSLT might not be reaching the browser, but I still get the image nodeID in the browser, even when I comment all code in the XSLT. Could the id in the browser be coming from the media picker alone. Even when I comment all code in the xslt I still get the id in the browser.
I have the following: topBanner.xslt with the attempts I've mentioned before. A topBanner macro and a master template with <umbraco:Item field="topBanner" runat="server">umbraco:Item>.
Hi again. I got it sorted. I had inserted a field instead of a macro into the macro assigned to the xslt. Now the picture and the textarea render in the browser.
On child pages I receive: Error parsing XSLT file: \xslt\topBanner.xslt. I still want recursion to occur, so all children to the master receive the banner. Any help would be appreciated.
Hello again. I've simply inserted a recursive property to the macro. Is this best practice? It seems to do the trick, in any case. <umbraco:Macro Alias="TopBanner" runat="server" recursive="true">
GetMedia 1-line image reference in 4.5.1 ?
Hi
I made a template with an image alias (mediapicker), alt tag (textstring) and linktitle (textstring)
In the old schema i used this on a clients webpage to reference childnode images (without setting variables):
I'vre read numerous topics on the forum regarding 4.5 schema image reference with GetMedia, but i can't get it to work, even when setting a variable first. Any suggestions?
Hi Martin
How about this line of code:
Does that work for you?
/Kim A
i think you may have to use /umbracoFile/Image -- but not 100% sure.
Guess it should be /Image/umbracoFile?
Cheers,
/Dirk
If i am not mistaking 4.5.1 has a bug with the GetMedia function, it gives back more than you expect
Try this:
Or if that doesnt work
Thanks for all your kind replies and help
Kim had the solution to this problem. But why?
I'm a bit confused about how there can be so many different suggestion to the same "little" problem. Is there somewhere i can pick up a book or another type of reference, that'll teach me correct xslt for the new schema?
Again thanks a bunch for all your help and inputs!
Hi Martin
I think the reason why there can be some confusion about the GetMedia-extension and path to the images is because of a bug in v4.5 where you needed to reference the root element of the media-element as well. If you take a look a Dirks answer and the first snippet that Niels provided you'll see that they both suggested an extra /Image to the path. Theese solutions will work if you had used v4.5, because of the bug.
But the bug has been fixed i v4.5.1 so that's why we don't need to use the extra /Image in the expression.
A good idea is to check how the XML looks by writing it out in a textarea. Like this:
You can do the same with $currentPage to see the XML on the current page, variables etc.. I think it's a good way of checking if we are writing the right XSLT. Does that make sense at all? :D
Anyway, I'm glad it worked out for you :)
/Kim A
Hi Kim
Don't worry it made sense. I've used the textarea trick before, but didn't think of it this time as i was too confused :-)
Thanks for the clarification and your help! I'm glad it worked too ;-)
Hej alle,
Har også kigget efter samme løsning og læste en del forslag som jeg prøver af. Sidder med 4.2 og har haft syntax problemer. Mener, den Kim nævner ovenpå fungerer... indtil videre... så længe så godt.
I hvert fald parser den i XSLT Visualizer. Kan få et fint file path, også et billedvisning ligefrem. Desværre bliver der returneret en nodeId i browseren.
Har en xslt-fil, macro med kald fra Master template. Har oprettet media picker på doctypen, som ligger øverste i hierarkien (forsiden). Vil gerne oprette en banner, som kan skiftes af brugeren/administratoren vha media picker. Nu er der to ting, der skal løses:
1. Billedet skal selvfølgelig vises fremfor nodeID.
2. Hvordan kan jeg få alle children til at vise samme banner (globalt), uden at jeg skal oprette en media picker på alle doctyper?
Hi Dwayne.
I'll take this one in english so that others can understand it as well. But you can go in danish if you preffer, that's up to you ;)
Could you show us your XSLT code that generates this node id in the browser? That would make things a lot easier to explain and debug.
/Kim A
Hey Kim. I'm new to the forum, and it didn't register I was writing in Danish until you answered. English is my native language, even. Crazy., ;~)
Okay, here's the short and skinny. I've been trying to run the XSLT after your suggestion. Am I missing something else in the XSLT file or will this stand alone when grabbing, setting and rendering a pic from the Media Picker?
Have also tried the Umbraco TV build exactly as they show it.
Lastly, I've tried the following. Someone explained on another thread in this forum it's the 4.5 syntax:
In any case, could I have forgotten a step in the dev process somewhere, or is it a question of missing/faulty code? Both?
... also, Kim, I've even inserted the textarea you mentioned as a developmental curiosity. I get it to render in the Visualizer but absolutely nothing shows in the browser. I'm wondering if it isn't something I've missed in the DEV process, but the fact that the browser shows an ID puzzles me. The macro must be passing something to the template.
Hi again Dwayne
When you say that you are running on an Umbraco version 4.2 are you then meaning v4.0.2 or 4.5.2? As far as I know there has never been a 4.2 and the XML schema has changed in v4.5 (and the media XML actually again in 4.5.1).
Is it this code that renders the id in the browser:
When you used the textarea, did you then see it on a page where there was an image selected in the topBanner-field?
/Kim A
Kim,
Yeah, that was a boner on my part - I meant 4.5.2. Latest version.
Something else is obviously wrong. The text area does not appear to be reaching the browser - it is not visible in the source code at all. Any ideas?
The XSLT might not be reaching the browser, but I still get the image nodeID in the browser, even when I comment all code in the XSLT. Could the id in the browser be coming from the media picker alone. Even when I comment all code in the xslt I still get the id in the browser.
I have the following:
topBanner.xslt with the attempts I've mentioned before. A topBanner macro and a master template with <umbraco:Item field="topBanner" runat="server">umbraco:Item>.
Hi again. I got it sorted. I had inserted a field instead of a macro into the macro assigned to the xslt. Now the picture and the textarea render in the browser.
On child pages I receive: Error parsing XSLT file: \xslt\topBanner.xslt. I still want recursion to occur, so all children to the master receive the banner. Any help would be appreciated.
Hi Dwayne,
If topBanner is a macro you should be using <umbraco:Macro> instead of <umbraco:Item> - the "Insert Macro" button does that for you.
/Chriztian
Hi Chriztian. Yeah, I figured that out right before you wrote. Thanks for the sharp eye ;~) I still want it recursive. See my previous post. Any help?
Hello again. I've simply inserted a recursive property to the macro. Is this best practice? It seems to do the trick, in any case. <umbraco:Macro Alias="TopBanner" runat="server" recursive="true">
is working on a reply...