[wp-hackers] Modular Themes: Apply the template hierarchy to folders within a theme

Stephen Rider wp-hackers at striderweb.com
Tue Apr 6 23:26:43 UTC 2010


Two things --

1) If you want a "theme framework" of common code, it seems you could emulate this now wuth judicious include()ing of files within whatever hierarchy of folders you like.

2) How would this affect child themes?

Stephen


On Apr 6, 2010, at 12:31 PM, Daryl Koopersmith wrote:

> I've recently been working on a patch and several posts explaining how
> modular themes can improve WP. For anyone who's seen my presentation from
> WordCamp Ireland, this is the patch I spoke about.
> 
> By applying the template hierarchy to folders within a theme, theme
> developers will be able to break themes into modules and substantially
> reduce repeated code.
> 
> If you look at Twenty Ten, it uses get_template_part() to simulate parts of
> the template hierarchy when loading the loop (e.g. it looks for
> loop-archive.php, then loop.php, etc.). However, any theme developer that
> wants to implement the template hierarchy while loading a template part must
> do so manually—there is currently no automated option. There are several
> downsides to a manual implementation, namely the lack of a naming convention
> and the sheer impossibility of implementing the entire template hierarchy by
> hand. This patch solves that problem.
> 
> In addition, modular themes have the potential to transform theme
> organization by reducing repeated code and making theme files more readable.
> 
> Based on my tests, this patch should not affect performance.
> 
> Interested?
> *  Trac ticket: http://core.trac.wordpress.org/ticket/12877
> *  Why we should add modular themes: http://wp.me/pS0xt-1f
> *  How they can transform theme organization: http://wp.me/pS0xt-30
> *  Performance tests: http://wp.me/pS0xt-3O
> 
> Finally, the patch has the added benefit of creating an accurate global
> $wp_template_hierarchy object (and a getter method), so any plugin/theme can
> access the template hierarchy for $wp_query.
> 
> Let me know what you think.
> 
> Thanks,
> Daryl
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list