I am building a website using umbraco v8, In the controllers section I am writing a code that calls other featured items in my front end website. But I am unable to call the Archetype model in my c# code. I know that umbraco v8 doesn't support Archetypes anymore but does anyone how what to use instead? I have been searching on the internet for hours but I couldn't get anywhere. Any help would be much appreciated.
Here is the code:
public ActionResult RenderFeatured()
{
List<FeaturedItem> model = new List<FeaturedItem>();
const int HOME_PAGE_POSITION_IN_PATH = 1;
int homePageId = int.Parse(CurrentPage.Path.Split(',')[HOME_PAGE_POSITION_IN_PATH]);
IPublishedContent homePage = Umbraco.Content(homePageId);
ArchetypeModel featureditems = homePage.Value("featuredItems");
foreach (ArchetypeFieldModel item in featureditems)
{
string imageUrl = "";
}
ActionResult result = PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml");
return result;
}
I have an Archetype field set which I can get an image from a Media Picker ok but am unable to retreive a simple textbox value. I know that when I haven't had UCPVC installed, in the following code, to get the H4 I'd just use fieldset.
Create your own Property Value Converter to convert the properties to a strongly typed model - However you won't be able to modify these properties in the Umbraco back office as ArcheType isn't available for v8.
(This is a better option), create a script to convert your Archetype properties into either Nested Content of Block Editor properties. You can parse and convert the JSON yourself to switch them around. This would, most likely, give you a much better long term situation.
ArchetypeModel is not supported in Umbraco v8
Hey Everyone,
I am building a website using umbraco v8, In the controllers section I am writing a code that calls other featured items in my front end website. But I am unable to call the Archetype model in my c# code. I know that umbraco v8 doesn't support Archetypes anymore but does anyone how what to use instead? I have been searching on the internet for hours but I couldn't get anywhere. Any help would be much appreciated.
Here is the code:
hi, I suggest you use Nested Content or Block List
https://our.umbraco.com/Documentation/Fundamentals/Backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content/
https://our.umbraco.com/Documentation/Fundamentals/Backoffice/property-editors/built-in-property-editors/Block-List-Editor/
https://umbraco.com/blog/deep-dive-the-block-list-editor/
I have an Archetype field set which I can get an image from a Media Picker ok but am unable to retreive a simple textbox value. I know that when I haven't had UCPVC installed, in the following code, to get the H4 I'd just use fieldset.
Hi Abhishek,
You'd need to take one of two options:
Create your own Property Value Converter to convert the properties to a strongly typed model - However you won't be able to modify these properties in the Umbraco back office as ArcheType isn't available for v8.
(This is a better option), create a script to convert your Archetype properties into either Nested Content of Block Editor properties. You can parse and convert the JSON yourself to switch them around. This would, most likely, give you a much better long term situation.
Thanks
Nik
is working on a reply...