I have written a module for my own use and wonder 1) if I have reinvented the wheel and 2) if others would find this useful. Thanks in advance for feedback.

As we know, we can create a unique template for the front page: page--front.tpl.php. But let's say we have an entire subsection of the site we want to theme with a template. Or perhaps just one specific page in a subsection. There is no easy way to do this, and using node ids in the template name is just poor programming practice.

Assume this site structure:



Front

-- Trees

---- Deciduous

------- How to plant

---- Non-Deciduous

------- How to plant



-- Plants

----- Flowering

With my module activated, I can now theme any page or subsection.

For example, /trees/Deciduous/How-to-plant can be themed by:



page--trees__deciduous__how-to-plant.tpl.php

page--trees__deciduous.tpl.php

page--trees.tpl.php

page.tpl.php

The suggestions are created by looking up the alias created by the Path module. They will be examined in this order, so that the most specific template will be used, just as we would expect.

So, is this reinventing the wheel? Would others find it useful?