Copied to clipboard

Flag this post as spam?

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


  • Mike Manusama 45 posts 195 karma points
    Jan 27, 2022 @ 14:20
    Mike Manusama
    0

    Getting page property values from a macro with content picker

    Hey all, I have a site on Umbraco 9 that I am rebuilding from 7.10. I had a macro that created a card. The card information displayed different property values from the page that was selected with the content picker.

    I used the code below which worked to grab the Url of the page that I selected, as well as the header image. This worked flawlessly, however, I am unable to get this to work in v9. Is there something that changed that I need to change as well? Thanks in advance!

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
    
        var linkTo = (IPublishedContent)Umbraco.Content(Model.MacroParameters["cardIntURL"]);
        var featuredImage = Umbraco.TypedMedia(linkTo.GetPropertyValue("heroBackgroundImage")).Url;
    
    
    
    }
    
    <div class="card card-article">
        <div class="card-head">
            <a class="article-link" href="@linkTo.Url">
                <img class="card-img" alt='@Html.Raw( @Model.MacroParameters["cardIntTitle"] )' src="@featuredImage" />
            </a>
        </div>
        <div class="card-content">
            <h3>@Html.Raw( @Model.MacroParameters["cardIntTitle"] )</h3>
            <p>@Html.Raw( @Model.MacroParameters["cardIntContent"] )</p>
        </div>
        <div class="card-button">
            <a class="btn btn-card article-link" href="@linkTo.Url">@Model.MacroParameters["cardIntBtnText"]</a>
        </div>
    </div>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies