Copied to clipboard

Flag this post as spam?

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


  • praveen 113 posts 164 karma points
    May 01, 2018 @ 03:59
    praveen
    0

    @Umbraco.Media(CurrentPage.promoBackGroundImg).Url not working

    Hi Please see the code in my partial. Unable to access CurrentPage, can you please advise any alternatives:

    enter image description here

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 01, 2018 @ 05:50
    Paul Seal
    100

    This should work

    @(Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("promoBackgroundImg").Url)
    
  • praveen 113 posts 164 karma points
    May 01, 2018 @ 10:15
    praveen
    0

    Hi Paul,

    Many thanks for your help, I am able to almost complete the first site in Umbraco 7 version.

    Your videos also helped me a lot to learn: https://www.youtube.com/watch?v=VWy2HlRDCRM&list=PL90L_HquhD--OWQNLyO1-KRxVDd0NPBfZ

    Kind Regards

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 01, 2018 @ 06:29
    Dave Woestenborghs
    1

    Hi,

    The problem is that you are starting your view with

    @inherits UmbracoViewPage
    

    The current page property is not available then, because UmbracoViewPage only supports strongly typed content access.

    To have the CurrentPage property your view should start with

    @inherits UmbracoTemplatePage
    

    Then you get access to the dynamic CurrentPage object. But I would discourage you to do that.

    Please read this article I wrote for the 24 days in Umbraco which explains the difference between strongly typed and dynamic content access https://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/

    And if you decide to go with strongly typed content access read this follow up article as well : https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/

    Dave

  • praveen 113 posts 164 karma points
    May 01, 2018 @ 10:16
    praveen
    0

    Hi Dave,

    Thanks for the post, this has give me an in depth knowledge.

    I owe you and Paul Seal a LOT

    you guys rock, many thanks for your help

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 01, 2018 @ 10:48
    Paul Seal
    0

    No problem. I'm glad you got it working and you found the videos useful.

Please Sign in or register to post replies

Write your reply to:

Draft