In the app I’m building, I’d like to have a nice footer with data from the database (tags) and a contact-form. All the parts are scripted, but now I’d like to put them all together.
The elements of the footer are the same for every page loaded, only the content is different.
How can I do this, without having to put too much code on every controller?
Use view helpers. Create a helper for each of the dynamic info, like the tags. And then you can have it’s output directly on the view. This avoids unnecessary code in the controller.
Here’s an example for the tags. Create a
Tags.phpfile containing:And now on your
footer.phtmlyou can use this like:You can use
partialLoop()to get a cleaner view.