Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1347 posts 1608 karma points
    Aug 12, 2016 @ 08:01
    Gordon Saxby
    1

    Controller confusion

    I have a page that lists a number of items - lets say events. For each one, I want a link to a page that will show the details of that event - but it is NOT the actual page / node where the details are stored, so it is just one page that will get the details based on a passed ID.

    Basically, I have something working but the "details" page shows a URL of "/umbraco/Surface/MemberEventsListing/MemberEventEntry/1208" ...

    How do I make the URL "/MemberEventsListing/MemberEventEntry/1208"?

    Or actually, I would like the URL to be "/members-home/events-list/event-details/1208". That is the hierarchy of pages in Umbraco.

    In a partial view (in a loop) I have this to create each "details" link

    @Html.ActionLink("View/Enter", "MemberEventEntry", "MemberEventsListing", new { id = item.EventId }, null)
    

    In the controller I have

        public class MemberEventsListingController : SurfaceController
        {
            public ActionResult MemberEventEntry(int id)
            {
                var eventPage = Umbraco.TypedContent(id);
                var model = new MemberEventEntry(eventPage)
                {
                 ... setup stuff
                };
    
                return View("~/Views/MemberEventEntry.cshtml", model);
            }
      }
    

    The view has

    @inherits UmbracoViewPage<MemberEventEntry>
    

    Any help or pointers to tutorials would be most welcome!

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Aug 14, 2016 @ 10:51
    Alex Skrypnyk
    0

    Hi Gordon,

    I would say that RenderControllers are more like what you need. You can add custom fields to view model at processing request and change View.

    Read more: https://our.umbraco.org/documentation/reference/routing/custom-controllers

    SurfaceControllers are more like form handling and it's not perfect for handling page requests.

    Thanks,

    Alex

  • 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