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!
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
In the controller I have
The view has
Any help or pointers to tutorials would be most welcome!
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
is working on a reply...