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 1460 posts 1881 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 6148 posts 24097 karma points MVP 8x 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

Please Sign in or register to post replies

Write your reply to:

Draft