Current Approach
Currently I render all my pagination results in a single element using a <table>
that has a header, body and footer structure. The rendering style is very spreadsheet like and this one element can handle paginated results for multiple controllers.
The Problem
I need to now support configurable rendering styles for the paginated results. The two main styles are spreadsheet and pinterest.com style (by pinterest I refer to vertical columns of varying lengths).
How To Implement
I'm looking for an answer on how to implement this using CakePHP 2.2 view features. Blocks, themes, and nested views. So that as much of the code is dry, and the configured part only applies the styling that is different.
The code to render the values in each tablet cell, the record title, and details like that should all be separated from the code that renders it either as a table or pinterest (or what ever you call that style).
Challenges
Each method in Cake seems to present limitations. What approach bests deals with the following?
- When each record is rendered, it will need different pre/post tags, and the same for each field in that record. Those tags are defined a lot by the style renderer.
- I may need to add features in the future like AJAX editing of a field value, and shouldn't need to modify the style handlers. So the style renderer should just deal with style.
- A lot of my style tags will involve
wrapping
presented data. What CakePHP method works best for that? - What's the best way to configure this? So that the paginate element knows which style to render.