Copied to clipboard

Flag this post as spam?

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


  • _R 13 posts 143 karma points
    May 17, 2023 @ 09:34
    _R
    0

    Access global properties in partial view using SiteBuilderBlock instance

    I am relatively new to Umbraco and I recently updated to umbraco 10, which is great. For our components we extended the functionality with the uSkinned components. What I want to accomplish is a partial view which must access some global properties configured at Homepage level.

    Currently all I have in my partial view is as follows:

    @inherits UmbracoViewPage<SiteBuilderBlock>
    @using USNSiteBuilder.Core.Models
    @using USNSiteBuilder.Core.Interfaces
    @inject ISiteBuilderService _siteBuilderService
    @{
        Layout = null;
        var test = Model.BaseModel.GlobalSettings;
    }
    
    <div>
        @await Html.PartialAsync("LicensePlate", Model)
    </div>
    

    What I want, is to access global properties from Homepage level, but I cannot find any property in the instantiated

    SiteBuilderBlock

    Class.

    The properties which are configured in this, so called, CTA group, are configured at the highest level of the project. The values themself are extracted properly.

    enter image description here

    In the partial view I want to access these values.

    Anyone any clue how to gracefully accomplish this?

  • _R 13 posts 143 karma points
    May 17, 2023 @ 10:12
    _R
    100

    Currently I found a solution. I can only extract values by there alias on PublishedContent. SiteBuilderBlock has a parented PublishedContent in it's BaseModel which can access the global properties by it's alias:

    Model.BaseModel.Parent.Value

    Now to be 100% safe, I need to search until parent == null since the properties are defined at top level page.

Please Sign in or register to post replies

Write your reply to:

Draft