|
Posted by Erwin Moller on 01/24/07 08:54
Frank van Wensveen wrote:
> Friend, coders, fellow wage slaves, lend my your ears.
>
> I believe that in a perfect world the design of a website (or feature
> on a website) should be totally separated from its design and the data
> it serves up. I'd like some suggestions on good ways to do this,
> because in the real world it can be quite difficult.
>
> For example, if I'm rummaging around in a MySQL database, the table
> structure and the code that generates the SQL requests are often
> interrelated. Restructure your table(s) and you have to update your
> code accordingly.
>
> Another, more serious issue is the separation of design from code. For
> example, if I'm using tables to divide my pages into separate 'blocks'
> (e.g. for a top bar, menu, content section, side bar, banner space,
> etc.) then the structure of these tables and table cells are
> interrelated with the program's flow: you set up a table or table
> cell, do something that outputs data into that cell, close the cell
> and/or table, and move on to the next cell to do something else there.
> Removing or adding a cell will mean that the function(s) that output
> data into that cell should or should not be called. Or the order in
> which code is executed could be affected: if I want a page-wide top
> bar cell followed by a menu column and a content window underneath, I
> need to render the top bar table row first, spanning two columns, then
> start a new table row in which I'd put the menu and content cell. But
> if I want a menu bar all the way to the top of the screen and a top
> bar cell followed by a content cell both to the right hand side of the
> menu column, I need to render the menu cell first, spanning two rows,
> and then progress to rendering the top bar and content cells.
>
> One could of course take abstraction and modularization to extreme
> levels (e.g. put every line of table-related code into a separate
> template file and include that depending on program flow) but this
> quickly increased both complexity and overhead to beyond what is
> acceptable. Not to mention the fact that ideally one should not issue
> function calls from within a content template file.
>
> So how do real developers do this?
>
Hi Frank,
Toby gave a nice response + examplecode.
I just want to add a fairly simple way to achieve the same: includefiles.
If you combine css with seperate files, you gain large flexibility when it
comes to changing layout, etc.
For example: If you have a navigationbar with many links (for admin eg),
just include a file that contains them.
You can simply include it above every page that uses it.
If you need to add/change anything, you have just one place to check.
Same goes for footers, or other parts of html.
It is easy to build, and easy to understand, and easy to implement, and easy
to change. :-)
Disclaimer: I am not claiming this approach is better than some
template/parsing engine. It is just another way to approach the subject.
Regards,
Erwin Moller
>
>
> Regards,
> Frank
Navigation:
[Reply to this message]
|