I'm working on a fairly large-sized project right now and have been putting priority on making it work before I make it look 'pretty'. But now I'm at a point where I need to consider how I'm going to layout this data I'm retrieving.
I have a few pages where based on an action variable and the level of access of the user, the page may retrieve different results and display different results. Right now, I'm doing basically two switch statements, collecting the data in an array, and then passing that array to a collective function that takes an array and displays it in a nice table form.
Here's the problem. Sometimes data sent in one element in the array might be a link, sometimes it might be text... What I want to do is somehow be able to separate it out so that I can use stylesheets in the layout function and just pass it data... i'd rather not use any layout information in the array (but unfortunately I do)...
I've thought of a few ways around this:
1) Make classes for each data type i'm going to be passing.. a "link" class, a simple "text" class, etc... then pass objects of these types to the function, which will find out what type it is an display accordingly (by manipulating the 'style' or 'target' of the 'link' object. This seems like alot of overhead however
2) Use a regular expression to figure out whether its a link or text, if it is a link, modify the style attribute (or class attribute) accordingly.
If anyone else has any ideas of how to separate out content from layout besides using crazy templating... and something that'll be easy to implement.. please inform me.. thanks.