Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi I am converting an old XSLT script to rasor and I am stuck on the syntax, any pointers would be gratefully received.
This is the section (in XSLT) I need to convert:
Basically I get a reference to the current node:
<xsl:variable name="nodeIds" select="umbraco.library:Split($currentPage/refreshCarousel,',')" />
then I for each through the values:
<xsl:for-each select="$nodeIds/value">
...in a ul li
<xsl:choose> <xsl:when test="$nodeIds/value != '' or $nodeIds/value > 0"> <xsl:variable name="slide" select="umbraco.library:GetXmlNodeById(current()/.)"/>
How does this translate to Razor?
Thanks
Hi Streety,
Maybe this post can help you in the right direction to convert your XSLT code to Razor
http://our.umbraco.org/forum/developers/razor/30232-razor-and-contains
/Dennis
Should be something like this:
@{ var nodeIds = Model.Content.GetPropertyValue<string>("refreshCarousel").Split(','); foreach (string node in nodeIds) { int id; <ul> @if (int.TryParse(node, out id)) { var slide = Umbraco.TypedContent(id); <li> @slide.Name </li> } </ul> } }
Thank you I'll try this.
Regards
Hmmm, is this code for the MVC version. Sorry I am 4.11.x
Missing assembly:
The type or namespace name 'TypedContent' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
Yeah, the code is for a Partial view. If you are using an old macroscript then it would be something like (from memory)
@{ var nodeIds =CurrentModel.GetPropertyValue("refreshCarousel").Split(','); foreach(string node in nodeIds) { int id; <ul> @if(int.TryParse(node,out id)) { var slide =Library.NodeById(id); <li> @slide.Name </li> } </ul> }}
. Hopefully that should be close enough :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Conversions to Razor issues.
Hi I am converting an old XSLT script to rasor and I am stuck on the syntax, any pointers would be gratefully received.
This is the section (in XSLT) I need to convert:
Basically I get a reference to the current node:
then I for each through the values:
...in a ul li
How does this translate to Razor?
Thanks
Hi Streety,
Maybe this post can help you in the right direction to convert your XSLT code to Razor
http://our.umbraco.org/forum/developers/razor/30232-razor-and-contains
/Dennis
Should be something like this:
Thank you I'll try this.
Regards
Hmmm, is this code for the MVC version. Sorry I am 4.11.x
Missing assembly:
Yeah, the code is for a Partial view. If you are using an old macroscript then it would be something like (from memory)
. Hopefully that should be close enough :)
is working on a reply...