You might have a look at how modX does it. You can create templates, but they are minimal because they are often incorporated with another resource, "chunks." Chunks can be anything, but they are static (headers, footers, redundant data. . . .) Enter third resource, "snippets" that allows you to incorporate small PHP snippets that are evaluated and executed - for anything not covered by a plugin.
So you can have a plugin that outputs menus (getResources, among other things) and put a call to the plugin inside a chunk, and reference the chunk in the template.
Enter a fourth resource, template variables, which are similar (but far superior) to Wordpress "custom fields." You assign the T.V.'s to a given template, and they become available to any document resource using that template. For example, "main page" TV's would have different functions that internal page TV's.
modX is truly a coder's CMS, bcause it's so customizable with short PHP snippets, but once set up is easy beans for the non-tech personnel managing it. It has it's down sides but still better than most O.S. wares out there.