[wp-hackers] Page Templates vs Category Templates
Haluk Karamete
halukkaramete at gmail.com
Thu Dec 2 19:59:30 UTC 2010
i am not a wp expert at all. and don't know the inner workings, but i
already see its power, and the flexibility it could offer.
i want to suggest one way to achieve what i was asking about. since
i'll be making this assumption with probably less than 5% of your
average know-how on wp, my chances are getting it right is pretty
slim, but hey, let's give it a shot.
pages got one loop and the loop pulls one record.
cats on the other hand has one loop too but that one matches one or
more records. so far, no conflict.
and the url tells WP as to what type to work with, is it a page or is
it a cat? - so far, no conflict.
both has their own page.php and category.php handlers - so far, no conflict.
and both of these handlers also understand from their own x-ID.php,
x-SLUG.php conveniences. so far, no conflict. but not a 100%
paralellism there. let me explain.
for some reason, when it comes to the page display, pages can go a
step higher ( that the cats ) and use any page templates if some
association has been made thru the page templates drop down at page
creation time. ( thanks to the <? template: whatever ?> one liner in
some page templates )
because of this cat-17.php at its highest hierarchy level when it
comes to category templates but page-13.php is not. pageWhatever.php
can overwrite that!
now.. what has lead to this end could be interesting study to find out
for the historically inclined among us but as for what can be done
from now on is what i am more interested in.
first of all, is it safe to say this...
no matter how you put it or how you defense it, common user would
naturally be baffled when they realize that the categories do not have
the same layout flexibility as the the pages do, though cats are the
breads and butter of the WP. Actually, they would have been less
surprised if actually pages were to one that lacked the feature.
i think sooner or later, categories are needed to be fixed to work
exactly the same way pages do. when that's done, we will also see
theme designers rushing into providing those extra category layouts
the same way they take to time to shop and brag about with the page
layout templates.
now, in order to make it function exactly the same way... can the
following be worked out?
at the top of *****category pages****, I suggest to add these two liners
<?
Template: My category layout page
TemplateType: category
?>
with these two liners, page UI's drop down would tend to pull those
category templates into the page templates drop down but I don't
think it is a major task to filter out those that also have the
templateType: category line in there.
So, with one minor modification, page UI may continue to work the same
way as it does now and the page layout drop down.
and by doing some work ( and u guys must step into plate cause i've
got 0 php background ), add category UI, will also get a similar drop
down . exactyl like the one page UI feaures ) and this one will pull
those those templates which have both Template and TemplateType
information where the TemplateType is 'category'.
so, that could take care of the UI.
of course this info got to be kept somewhere for the cats.. but it
shouldn't be that hard cause that kind of thing is already being done
for the pages. since i do not know how WP does these things, I'm
clueless as to what tables to go to, what hooks to work with. it
conceptually appears to me as doable. that's all.
in this case, pages will continue to work with the hierarchy as follows;
any page template takes the top slot and then
page-x.php, then page-slug.php, then page.php
but that's no news. we already know that!
but categories will match that as follows;
any category template ( one of those that's got both Template :
whatever and TemplateType: category and is also associated with one
category )
category-x.php
category-slug.php
category.php
now, as to the url interpretation,
wp already figures out from the url if it is a page type, and if so
to go look for the associated page template's for the page and work
with it.
so why can't it figure out if it is a cat type, then look for the
associated category template for that category, and work with it?
with this trick, if I have 300 cats, and say the first 100 happen to
use 1 column layout, the second 100 happen to use 2 colomn layout, and
say the last 100 use 3 colomn layout, I do not have to get into php
tricks to pull this off and i just select one of the avaiable category
templates from the category template. done.
and for that to take place, all the user needs to do is to pick a
theme that comes with those additional category templates, and @
adding-a-category-time, choose 1 or 2 or 3 colomn layout.
with this approach, existing themes and templates and page UI will
continue to work the same way with absolutely no change in any part of
the codex ( except page template drop down needs to filter out those
templates with the template type:category extra line in them).
is this a long shot?
On Thu, Dec 2, 2010 at 3:27 AM, Philip M. Hofer (Frumph)
<philip at frumph.net> wrote:
> Yeah reading the thread, it's not as difficult as you guys are making it,
> doing the template_part and doing "if (in_category('categoryname')) in the
> layout parts would work just as well"
>
> In the theme's setting pages you can probably also define which categories
> get which layouts too, which would be quite a bit easier then hardcoding.
>
>
>
>
> ----- Original Message ----- From: "Philip M. Hofer (Frumph)"
> <philip at frumph.net>
> To: <wp-hackers at lists.automattic.com>
> Sent: Thursday, December 02, 2010 3:10 AM
> Subject: Re: [wp-hackers] Page Templates vs Category Templates
>
>
>> Ah yeah I do that in comicpress with a drop down selection of which layout
>> the user wants to use.
>>
>> In the header at the very bottom I put a
>> get_template_part('layout','head'); and first line of the footer
>> get_template_part('layout','foot'); which handles the layout code, and based
>> on the user selection I wrote an if
>> (comicpress_is_layout('standard,vertical')) { then handle it. each of the
>> pages only contains the 'content' of those specific pages, while the layout
>> pages handle the sidebars etc how the content is displayed, etc.
>>
>> Think I have 11 different layouts, most with their own widths and some
>> without certain sidebars etc.
>>
>> Catching up on reading the whole thread right now.
>>
>>
>>
>> ----- Original Message ----- From: "Mike Little" <wordpress at zed1.com>
>> To: <wp-hackers at lists.automattic.com>
>> Sent: Thursday, December 02, 2010 2:58 AM
>> Subject: Re: [wp-hackers] Page Templates vs Category Templates
>>
>>
>>> On 2 December 2010 10:39, Philip M. Hofer (Frumph)
>>> <philip at frumph.net>wrote:
>>>
>>>> Mike, quick question..
>>>>
>>>> You want to basically have each category have their own look right?
>>>>
>>>> You know you can do this with CSS and a body_class() filter right?
>>>>
>>>> - Phil
>>>>
>>>>
>>> Yes, of course.
>>>
>>> The topic is essentially about being able to select *theme provided*
>>> layouts
>>> on a per category basis (similar to how you do for page templates -- and
>>> they could be the same ones) for people who are not up to
>>> creating/modifying
>>> themes.
>>>
>>> Mike
>>> --
>>> Mike Little
>>> http://zed1.com/
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
> _______________________________________________
> 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