ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How far can I push categories?

March 10, 2011 4:38pm

Subscribe [3]
  • #1 / Mar 10, 2011 4:38pm

    roryrabbitfield

    320 posts

    I have a single template:
    /fitness/index

    And there is a classes channel, with lots of categories. The template a bunch of links to show those channel entries in that same template, filtered by category. For example:
    /fitness/category/women

    This link shows the “women” category, using the /fitness/index template.
    Other links show you the other categories in various groupings.

    Question is: at the top of the page, I want 2 images, with links, and I want each category to have its own pair of images/links. How can I do that? I know I can assign an image to a channel, but I need more than that. I need 2 images, and I need to have the URLs that are in the links tags for those images be editable by the client. The links will point not to the template showing that channel, but to any random place.

    So far all I can come up with is to create a “promos” channel with 4 fields, to hold the 2 images & the 2 link URLs, and make an entry to correspond to each category and use conditionals to say, “if category X, show the ‘promos’ channel entry with this ID#”.

    But that’s so messy, I’d have to hard code all those conditionals, and then what if we change the categories?

    Is there a better way? A way to get more functionality from the categories? Is there some way to do this more cleanly that I am not thinking of?

    Any suggestions you have about how to do this intelligently are welcome.

  • #2 / Mar 10, 2011 5:57pm

    Boyink!

    5011 posts

    Did you mean to say you know you can assign an image to a category (vs. a channel)?

    You could possibly just add custom category fields for the other image/link.

  • #3 / Mar 10, 2011 6:07pm

    roryrabbitfield

    320 posts

    Yes, I did mean to say I know I can assign an image to a “category”, not channel.

    I had no idea you could create custom category fields. I am looking into that now. I found this:
    http://ellislab.com/expressionengine/user-guide/cp/admin/content_admin/category_field_management.html

  • #4 / Mar 10, 2011 6:08pm

    roryrabbitfield

    320 posts

    Oh, wait. It looks like custom category fields can only be text input, text area, or a select list. So I still see no way to add a 2nd image.

  • #5 / Mar 10, 2011 6:11pm

    Boyink!

    5011 posts

    Well, in reality the native “image” field is just a text field where you enter a path.  There is no native “file upload” ability there. I’ve seen some 3rd party addons for changing that, but don’t think they add the ability to have other field types at the category level.

    This might be a case where ditching categories entirely and using relationships instead might make more sense.

  • #6 / Mar 10, 2011 6:12pm

    bleep

    9 posts

    Not sure I follow, but why do you have to hard code the the conditional? If you tag the images/links to a category per entry, in the Features channel you could have the code match the promo block to the categories based on segment_3.

    You’ll end up with a series of entries for each promo… but that seems OK?

    Though it’s possible I misunderstand completely as I’m new to EE.

    If you were using Structure you could have a series of pages under Fitness, with the custom image/link fields for each category, and that would give your client a logical way of navigating the content. If you have a lot of categories under Fitness that would become unwieldy…

  • #7 / Mar 10, 2011 6:20pm

    Boyink!

    5011 posts

    Actually this could be done another way:

    1. Create a category group
    2. Create two channels - one for images and one for the main content
    3. Publish entries to both channels, assigning them to the correct category
    4. Assign both channels to the same category group
    5. Have two channel:entries loops, left in dynamic mode, on your index template
    6. Load the page at a category URL and both entries loops will dynamically filter to showing just category content.

  • #8 / Mar 10, 2011 6:22pm

    roryrabbitfield

    320 posts

    Oh! I think a light bulb just went off. Let me experiment with that. I hope I can figure it out. Thanks, all!  😊

  • #9 / Mar 11, 2011 6:13am

    John Henry Donovan

    12339 posts

    Thanks Mike.
    Let me move this to the CodeShare Corner in case you wish to follow up Rory

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases