Jump to content

Yet Another way of using templates


Joss
 Share

Recommended Posts

Just reading Soma's post on delegation and thinking about how I am using functions more and more, I am wondering if I can sort of mix and match.

Basically, it more or less follows what Soma is doing, but in addition, using the template name to define additional includes or functions (however you are working).

So, you would perhaps have a template that you called category-news-headlines

Exploding the name gives you three parameters - category, news and headlines

Category would be the name for this particular template for purposes of differentiation but also may be defining that this is listing something by category.

News might be the general theme you are calling in, a wrapper theme with a certain layout style or something

Headlines would be something more specific, perhaps - some way of laying out the actual articles that has a big main article, is looking for featured content or something.

Another variation would be a template called category-news-list which does the same thing, except the news would just appear as a list.

On the actual template file, you split up the template name and use the parameters to call in the right elements.

The advantage here is that you can create more variations without actually having to create more than a basic set of included files or functions. You are simply mixing and matching.

This only works on a site (or a sections of a site) where you are using identical fields for all the templates.

Of course, there is a rather valid argument that it would be better (and a lot easier) just to define the additional parameters

with select/pages fields, but it is an idea that might have other uses.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...