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 use umbraco 4.11.5
I am trying to use MultiType data type but can not get it to work in frontend
it works in the backend of umbraco with this XLST script
<xsl:param name="currentPage"/>
<xsl:param name="Name" />
<xsl:param name="Alias" />
<xsl:param name="Value" />
<xsl:param name="SortOrder" />
<xsl:template match="/">
<xsl:if test="$Name = 'Billede'">
<xsl:variable name="mediaId" select="number($Value)" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="$mediaNode/umbracoFile">
<img src="{$mediaNode/umbracoFile}" height="15%"/>
</xsl:if>
<xsl:if test="$Name != 'Billede'">
<span class="value">
<xsl:value-of select="$Value"/>
</span>
<xsl:text> </xsl:text>
where you can find some example of xslt or razor script to frontend
Hi Brian,
To have a look at the structure created by the multitype try this:
<umbraco:Item field="multiTypeTest" runat="server" />
You wont see anything on the page but take a look at the source you should see something like:
<items> <item id="1" sortid="1"> <heading><!--[CDATA[Ben]]--></heading> <text><!--[CDATA[Hello]]--></text> </item> <item id="2" sortid="1"> <heading><!--[CDATA[Tom]]--></heading> <text><!--[CDATA[Goodbye]]--></text> </item> </items>
Obviously with your data inside, then you can use some razor on the page like:
<umbraco:Macro runat="server" language="cshtml"> @{ foreach (dynamic item in Model.multiTypeTest) { <h2>@item.heading</h2> <p>@item.text</p> } } </umbraco:Macro>
Where Model.multiTypeTest matches whatever the name of your multitype property is on the document type.
Hopefully this makes sense and you can adapt it to work for you, any problems just let me know.
ThanksBen
thanks it was just what I needed :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Multitype datatype simple script to frontend
Hi
I use umbraco 4.11.5
I am trying to use MultiType data type but can not get it to work in frontend
it works in the backend of umbraco with this XLST script
<xsl:param name="currentPage"/>
<xsl:param name="Name" />
<xsl:param name="Alias" />
<xsl:param name="Value" />
<xsl:param name="SortOrder" />
<xsl:template match="/">
<xsl:if test="$Name = 'Billede'">
<xsl:variable name="mediaId" select="number($Value)" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="$mediaNode/umbracoFile">
<img src="{$mediaNode/umbracoFile}" height="15%"/>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:if test="$Name != 'Billede'">
<span class="value">
<xsl:value-of select="$Value"/>
</span>
</xsl:if>
<xsl:text> </xsl:text>
where you can find some example of xslt or razor script to frontend
Hi Brian,
To have a look at the structure created by the multitype try this:
You wont see anything on the page but take a look at the source you should see something like:
Obviously with your data inside, then you can use some razor on the page like:
Where Model.multiTypeTest matches whatever the name of your multitype property is on the document type.
Hopefully this makes sense and you can adapt it to work for you, any problems just let me know.
Thanks
Ben
thanks it was just what I needed :-)
is working on a reply...