Copied to clipboard

Flag this post as spam?

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


  • pranjal 75 posts 188 karma points
    Jan 19, 2018 @ 09:23
    pranjal
    0

    Access umbraco Content in Surface Controller

    How to access content data in Umbraco Surface controller. I want to access the content data in surface controller

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Jan 19, 2018 @ 09:24
    Damiaan
    1

    Just use

    var content = Umbraco.TypedContent(idOfTheNode);
    

    Hope this helps

  • pranjal 75 posts 188 karma points
    Jan 19, 2018 @ 09:26
    pranjal
    0

    In my case i have a blog section in which listview of blogs is generated now i want to get all blog list and data in surface controller so i will add my custom logic there.

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Jan 19, 2018 @ 09:34
    Damiaan
    3

    Most of the time, a SurfaceController is used for rendering MVC Child Actions and for handling form data submissions.

    If you do the listview as a child action you could use a SurfaceController. Other ways would be a simple partial, just a template when passing in the model with a custom RenderMvcController or a Macro.

    Good luck with it!

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 19, 2018 @ 13:25
    Dan Diplo
    0

    I'd agree with Damiaan - sounds like you need a RenderMvcController rather than a SurfaceController.

  • John Bergman 483 posts 1132 karma points
    Jan 20, 2018 @ 04:27
    John Bergman
    0

    If there is a compelling reason to use a surface controller, (we have had a couple of cases), you need to pass the page Id into the method that does the rendering or have a way to determine what the page id is of the document you want to render.

    I agree with the others though, generally speaking a RenderMvcController seems like the way to go.

  • 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