Copied to clipboard

Flag this post as spam?

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


  • D1835 7 posts 77 karma points
    Feb 13, 2024 @ 10:18
    D1835
    0

    'SiteBuilderBaseViewModel' does not contain a definition for 'CustomBlockList'

    I want to render the content of my blocklist on the nav of my website, however, I get this error:

    SiteBuilderBaseViewModel' does not contain a definition for 'CustomBlockList' and no accessible extension method 'CustomBlockList' accepting a first argument of type 'SiteBuilderBaseViewModel' could be found.

    @inherits UmbracoViewPage<SiteBuilderBaseViewModel>
    @using USNSiteBuilder.Core.Models
    @using USNSiteBuilder.Core.Interfaces
    @{
        Usnnavigation navigation = (Usnnavigation)Model.Navigation;
    
        if (navigation != null && navigation.CustomNav!= null && navigation.CustomNav.Any()) {
    
            int index = 1;
    
            foreach (var item in navigation.CustomNav) {
                <li><span><a href="#">item @($"{index}")</a></span></li>
                index++;
            }
    
            @Html.GetBlockListHtml(Model.CustomBlockList)
        }
    
    }
    

    I have followed the docs and created the Components folder under blocklist. The file inside is "CustomBlockList.cshtml":

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem>;
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @{
        var content = (ContentModels.CustomBlockList)Model.Content;
    }
    
    <h1>@content.PageName</h1>
    

    The final goal is to render what's inside the Block list and not the item @($"{index}"). Can anyone help?

  • Marc Love (uSkinned.net) 432 posts 1691 karma points
    Feb 13, 2024 @ 11:45
    Marc Love (uSkinned.net)
    1

    Hi,

    I can see that you are using uSkinned Site Builder. Marc from uSkinned here.

    To access your custom block list you will need to use:

     @Html.GetBlockListHtml(Model.Value<BlockListModel>("customBlockList"))
    

    Cheers,

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft