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
    Sep 10, 2021 @ 18:07
    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 388 posts 1360 karma points
    Sep 10, 2021 @ 23:31
  • Malloy 1 post 71 karma points
    Sep 11, 2021 @ 05:07
    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 1617 posts 7263 karma points MVP 7x c-trib
    Sep 11, 2021 @ 14:44
    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