Hi all. Just dipping my toe in the Umbraco waters. I want to extend one of the built in XLST templates (or just use a new one from scratch if I need to).
I have a Listings page and on that page I want to display the children of that page, and along side the title (which I currently have), a thumbnail (date type = 'propertyThumbnail') and potentially other data types for that page.
I've tried a few techniques but they haven't worked as I think they are using the old code format?
The propertyThumbnail is currently a Media Picker, in case that makes a difference?
So if anyone can help, that would be great. Thanks
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- The fun starts here --> <ul id="nav"> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul>
Before we move on, what's the datatype of your propertyThumbnail property? Is it a media picker, an upload? Something else? Does it have to be thumbnail of an uploaded image.
the data type is Media Picker. And we intend for to always be an image. So they upload an image to the media gallery and then choose from that, rather than uploading straight from their machine.
On the detail page, I can get the src of the image to be "0001" (or whatever it is), so I need to bring back the fullpath? But anyway, that is another issue.
If datatype is media picker, then the id of the media item is stored. And using umbraco.library:GetMedia(nodeId, false()), you can get info on the media item, including the full path
the errors occours because Umbraco tries to run the code when you save the file. This means that the GetMedia extension will fail. So try wrapping the line inside of a <xsl:if> like this:
An unknown error occured while rendering the following code:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:
'umbraco.MacroEngines.DynamicNode' does not contain a definition for
'numberOfBedroom'
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite
site, T0 arg0)
at RazorEngine.Dynamic.fdedabeaadce.Execute()
at RazorEngine.Templating.TemplateService.Parse[T](String template, T
model, String name)
at umbraco.MacroEngines.RazorEngine.GetResult(String cacheIdentifier,
String template, INode currentPage, String& result)
NOOB help. Displaying page thumbnail
Hi all. Just dipping my toe in the Umbraco waters. I want to extend one of the built in XLST templates (or just use a new one from scratch if I need to).
I have a Listings page and on that page I want to display the children of that page, and along side the title (which I currently have), a thumbnail (date type = 'propertyThumbnail') and potentially other data types for that page.
I've tried a few techniques but they haven't worked as I think they are using the old code format?
The propertyThumbnail is currently a Media Picker, in case that makes a difference?
So if anyone can help, that would be great. Thanks
Before we move on, what's the datatype of your propertyThumbnail property? Is it a media picker, an upload? Something else? Does it have to be thumbnail of an uploaded image.
Let us know and we'll see how we can help you.
Cheers,
/Dirk
Hi Dirk.
the data type is Media Picker. And we intend for to always be an image. So they upload an image to the media gallery and then choose from that, rather than uploading straight from their machine.
On the detail page, I can get the src of the image to be "0001" (or whatever it is), so I need to bring back the fullpath? But anyway, that is another issue.
If datatype is media picker, then the id of the media item is stored. And using umbraco.library:GetMedia(nodeId, false()), you can get info on the media item, including the full path
will get you the full path of the media item
(Assuming alias of your property for the media picker is 'propertyThumbnail')
Cheers,
/Dirk
Putting that in my XLST and trying to save gives me loads of errors
Hi Tom.
the errors occours because Umbraco tries to run the code when you save the file. This means that the GetMedia extension will fail. So try wrapping the line inside of a <xsl:if> like this:
This should give you the full pah to the image, without throwing an error when you save he file.
/Kim A
Hi Tom
I'll just like to make an addition to the above. You can see some good examples on the usage of the GetMedia extension in the wiki here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
/Jan
Oh, and of course if you want to render the path in an image-tag you can do like this:
/Kim A
Hi guys. I'm actually prefering the syntax using the Razor scripting.
I've been looking at this thread, but still can't get the image to display:
http://our.umbraco.org/forum/developers/api-questions/16293-Calling-the-Umbraco-GetMedia-function-from-Razor-macro
current code
Which gives me some horrible feedback
An unknown error occured while rendering the following code:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'numberOfBedroom' at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at RazorEngine.Dynamic.fdedabeaadce.Execute() at RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String name) at umbraco.MacroEngines.RazorEngine.GetResult(String cacheIdentifier, String template, INode currentPage, String& result)
Your Razor template:
<ul class="listings"> @foreach(var page in Model.Children) { <li> <h2><a href="@page.Url" title="@page.Name"><img src="@umbraco.library.GetMedia(System.Int32.Parse(page.propertyThumbnail), false)/umbracoFile"/> @page.Name</a></h2> <p>@page.overview</p> <a class="more" href="@page.Url">More details @page.numberOfBedroom bedrooms and brochure</a> </li> } </ul>
Cache key:
1053-ForSale-
And I'm back :)
OK so the error was my fault.
But still no joy displaying an image using the Razor file. Any thoughts?
is working on a reply...