Separate theme files for posts
-
I’m not sure if this is something that has come up before since I’m not sure what keywords to search on. A quick search on Google didn’t show anything, but if there is already a thread for this I’d appreciate knowing about it.
Anyway, I would like to see theme files become more modular. Right now the header, footer and sidebars are usually separate files but the main theme file is responsible to call them. And it is more of a convention rather than a requirement.
It would be nice if the styling for individual posts and excerpts could be separated out so that they can be reused. This would help in keeping the theme files up to date when a change is made to the markup — it is only in 1 file rather than in each file that has a loop.
It could even be abstracted a couple levels deep, the main file for a page, calls separate files to build the header, content, sidebar and footer. The content file would then call in the post or excerpt file (depending on which is needed) as part of its loop.
This would also allow a plugin to track down the standard formatting for a post or loop used in the theme and use them if required.
I think that Drupal and XOOPs use a model like this. The biggest issue that I see with moving this direction would be backwards compatibility for themes. Any code or plugin written to take advantage of this structure would not work in an older theme.
Anyway, what do you guys and gals think of this idea?
- The topic ‘Separate theme files for posts’ is closed to new replies.