-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup SurfaceController for Events #39
Comments
Hello, I've been tinkering with controllers (not done loads with them tbh) whilst I've been playing around with Setup Events and Event doctypes #36. A few questions if thats okay. How would people pass the 'event' children to the view (the event landing page that lists the children) ? - Would you create a scaled-down 'eventItem' class to model of an event page? This would be used for list items e.g. new classes
ViewModel
controller
eventslanding page view
I am unsure what the standard practice would be and whether the above is overkill seems as you have access to the event child model e.g. Model.Children.OfType()? Do you do all the processing in the view e.g. formatting the dates .tostring("MMMM dd yyyy") in view, use all the available HTML helpers to do things like truncating e.g. @Html.Truncate, and LINQ to order children? What's the preference here? My understanding is that this starter kit is designed to help people who might be unfamiliar with Umbraco learn about it so I don't want to lead them up the wrong path. Plus its good for my learning also :) Good to get your thoughts on this :) |
Hey sure thing :) well currently we are thinking of using surface controllers to handle that... so not route hijacking... A small example can be found in the hybrid framework... That way we can keep it DRY... So no need for an EventsLandingPageViewModel and a custom @inherits Umbraco.Web.Mvc.UmbracoViewPage a scaled down version makes sense... maybe call it teaser? and use the default mapper used in umbraco to map from full to teaser? https://our.umbraco.com/documentation/Reference/Mapping/ Does that make sense? |
Hey Tim, such a busy day! I need to read up some more on the differences\advantages between surface controllers and route hijacking. I seem to use surface controllers whenever I do a contact form and route hijacking any other time. I've probably found a tutorial to follow at the time :) Thanks for the links |
Yes, that is what most do... but say you have an events landing page and an events widget on home... both need to fetch events data... to keep it DRY best is to handle that in a single controller ... can't do that when doing route hijacking... I'll see if I can find a good example tomorrow :) |
Thanks, Tim, examples are always good if you have them. The DRY principles makes sense with the surface controller. I would always create HTML.Action() calls to a home page controller but you are essentially doing the same thing. Looping through children to process a list item etc. All learning for me 👍 |
In order to keep things as DRY as possible we'll use a surface controller to handle the events fetching, both from a homepage widget and the events page
The text was updated successfully, but these errors were encountered: