Community Forums › Forums › Archived Forums › General Discussion › A better way to create custom category pages
Tagged: custom categories
- This topic has 2 replies, 2 voices, and was last updated 9 years, 3 months ago by TurboPoet94.
-
AuthorPosts
-
December 10, 2014 at 8:04 am #134160TurboPoet94Member
Hi, I'm working on a project for a news/magazine site where every post is broken out into one of 21 possible categories.
The marketers I'm working with would like each of those 21 possible categories to have their category pages laid out in one of 5 basic templates.
So I'm looking at say 5 categories that use template style #1, 4 cats that use template style #2, etc., etc., etc.
I know I could take a category that's called "abstract-expressionism" and simply create a "category-abstract-expressionism.php" template that does what I need it to do...
...and take a cat that's called "impressionism" and do the same thing - create a "category-impressionism.php" template...
...and do this for all 21 categories.
And let me say that - sadly - I am a caveman when it comes to things like this. That is, my first instinct is to just build 21 "category-foo-bar.php" templates, but I have a feeling that the Brian Gardener's, Bill Erickson's and many of you folks would take a better strategy that doesn't involved using 21 .php files.
What would you approach be?
I have it in my head that a Gardener/Erickson type would some how have a single file that does everything - that tests for categories and then does layout/queries etc. based on a series of conditionals.
At the very least, I think they'd have 5 custom category templates that are being applied to each of the 21 categories.
Any ideas for someone who freely admits his knuckles are dragging on the ground?
December 10, 2014 at 10:55 am #134201anotherusernameParticipantHmmm...
Basically, what you NEED would be only 5 templates... assuming that they were competent enough to use the right template for each category.
Is there a conditional for choosing the template based on what the category id / slug is?
In the meantime, you could create the five templates with a sample name, and then copy / paste / rename them so you would have the total of 21 categories with the category-specific names.
You could use that until you figured out the conditional for using the template based on category id.
Hope this helps.
December 12, 2014 at 9:27 am #134377TurboPoet94MemberThanks! For now, I ended up being able to use conditionals inserted at a few Genesis hooks to get me started (i.e. if you are apples, then here's the sidebar for apples).
"Is there a conditional for choosing the template based on what the category id / slug is?" - that's what's throwing me. I want something that says
If cat="apples", then be a category page that is accessed via domain.com/category/apples and use template #1. And template #1 will (in theory) figure out what do to based on category being "apples".
I don't know how to tell Genesis: "Okay, the page we're rendering is domain.com/category/apples and the cat ID=5521. So, for this category, please don't go to the "category.php", and don't go to "category-apples.php", but go to "name-of=-layoutPattern-1.php" instead...
...but still be domain.com/category/apples.
Anyway...
...thanks for the advice.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.