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
I have a page with 3 Archetype properties and I've found this piece of Razor on the forum:
@{ var desktop = CurrentPage.Content.GetPropertyValue<ArchetypeModel>("desktop_archetype") var tablet = CurrentPage.Content.GetPropertyValue<ArchetypeModel>("tablet_archetype") var handheld = CurrentPage.Content.GetPropertyValue<ArchetypeModel>("handheld_archetype") foreach (var fieldset in desktop) { if (fieldset.Equals(slider.First())) { <p>True</p> } else { <p>False</p> } } }
But it keeps failing on me with this message:
The type or namespace name 'ArchetypeModel' could not be found (are you missing a using directive or an assembly reference?)
I'm doing this in a regular template which has this line in the top.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
And I've tried to use CurrentPage and Model but with no luck whatsoever.
I know I'm new at this, but what am I doing wrong ?
using Archetype.Models;
I'm using the latest version of Archetype.
My code looks : Model.Content.GetPropertyValue
Thanx, now it doesn't fail :)
But it's like it doesn't see any fieldsets
@{ var desktop = CurrentPage.Content.GetPropertyValue("desktop_archetype"); if (desktop.Fieldsets.Any()) { <p>Fieldsets</p> } else { <p>No fieldsets</p> } }
This return "No fieldsets"
What version of Archetype you are using?
I'm using 1.4.1
Sorry I posted invalid code sample: Now is right part of code Model.Content.GetPropertyValue<Archetype.Models.ArchetypeModel>("PROPERTYNAME")
Model.Content.GetPropertyValue<Archetype.Models.ArchetypeModel>("PROPERTYNAME")
Hi Sebastian
have you included the Extensions namespace? https://gist.github.com/kgiszewski/8863822
@using Archetype.Models;@using Archetype.Extensions;
An example:
<div class="row"> @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("featuredBoxes")) { Umbraco.Web.Models.DynamicPublishedContent media = Umbraco.Media(fieldset.GetValue("icon")); var heading = fieldset.GetValue("heading"); <section class="col-md-4"> <img src="@media.Url" alt="@media.Name" /> <h3>@heading</h3> <p>@fieldset.GetValue("shortDesc")</p> </section> } </div>
/Bjarne
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to render Archetype with Razor ?
I have a page with 3 Archetype properties and I've found this piece of Razor on the forum:
But it keeps failing on me with this message:
I'm doing this in a regular template which has this line in the top.
And I've tried to use CurrentPage and Model but with no luck whatsoever.
I know I'm new at this, but what am I doing wrong ?
using Archetype.Models;
I'm using the latest version of Archetype.
My code looks : Model.Content.GetPropertyValue
Thanx, now it doesn't fail :)
But it's like it doesn't see any fieldsets
This return "No fieldsets"
What version of Archetype you are using?
I'm using 1.4.1
Sorry I posted invalid code sample: Now is right part of code
Model.Content.GetPropertyValue<Archetype.Models.ArchetypeModel>("PROPERTYNAME")
Hi Sebastian
have you included the Extensions namespace? https://gist.github.com/kgiszewski/8863822
@using Archetype.Models;
@using Archetype.Extensions;
An example:
/Bjarne
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.