I have a “standard” page layout.
A header, a footer, a main block of content on the left hand side and a sidebar on the right hand side.
Now this is all well and good, except the sidebar is replicated in each and every controller, but needs a controller to function. Sometimes the user might be logged in and therefore there will be some working out of name and such there. Also there is going to be a shopping cart there which will run from a MySQL database.
I don’t want to replicate this code in each of my controllers.
How would I make a controller that will build the sidebar, load the view and everything that I can then “include” (like I would include a view) into the page.
I can forsee the creation of a sidebar class/object which I could instantiate and “add to the view” as it were.
How am I supposed to do this?
Thank you
I eventually created a library which did the stuff I needed. This works well. Libraries can be made effectively like simple controllers and included into them anywhere. 🙂