Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Abhishek Narvekar 4 posts 74 karma points
    1 week ago
    Abhishek Narvekar
    0

    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:

    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;
        }
    
  • Marcio Goularte 358 posts 1251 karma points
    1 week ago
  • Malloy 1 post 71 karma points
    1 week ago
    Malloy
    0

    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.

  • Nik 1470 posts 6482 karma points MVP 4x c-trib
    1 week ago
    Nik
    0

    Hi Abhishek,

    You'd need to take one of two options:

    1. 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.

    2. (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

Please Sign in or register to post replies

Write your reply to:

Draft