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.

Multiple categories with dynamic parameters

May 09, 2012 11:24am

Subscribe [1]
  • #1 / May 09, 2012 11:24am

    willm

    30 posts

    In the docs it states that all channel:entries parmeters can be used as dynamic parameters.

    What’s the correct way to set up multiple categories in this way, e.g. a list of category checkboxes. I’m thinking something like the following (where the categories tag generates the list of available categories for inputs):

    <form method="post" action="{path='{segment_1}/{segment_2}'}">
    {exp:channel:categories
     channel="news"
     category_group="2"
     parent_only="yes"
     show_empty="no"
     style="linear"
    }
    <label for="cat1">
     <input type="checkbox" id="cat1" name="category[]" value="{category_id}">{category_name}
    </label>
    {/exp:channel:categories}
    </form>

    All other dynamic parameters are working fine, but I can’t get these multiple categories to work. Has anyone ran into a similar problem?

  • #2 / May 09, 2012 3:17pm

    willm

    30 posts

    Just to confim, I’m not having a problem with the output of the categories tag, that’s working fine.

    What I’m having a problem with is generating the dynamic entries, which don’t seem to filter on the categories when submitting the form.

  • #3 / May 10, 2012 12:32pm

    Dan Decker

    7338 posts

    Hi willm,

    Thanks for your question!

    Have you tried hardcoding one category ID, to see if that works?

    The challenge here is that the category parameter in channel entries accepts a pipe delimited list, and your checkbox input are going to be passed over as an array.

    Try this:

    <input type="checkbox" id="cat1" name="category[]" value="{category_id}|">{category_name}

    I added the “|” to the end of the ID value. That should build the proper list for the category parameter.

    I look forward to your reply!

    Cheers,

  • #4 / May 16, 2012 3:36pm

    willm

    30 posts

    Checking out some other forum posts, it seems category[] can’t be used to join parameters in conjunction with dynamic parameters. It can be done with Dynamo though!

    One thing that EE can’t do, but would be really useful, is being able to use both a pipe and ampersand to join category parameters. At present you can only use them on their own, but it would be great if you could do this:

    category="1&4|1&5|1&6"

    It would make filtering a lot more flexible! I’ll submit it as a feature request

  • #5 / May 21, 2012 4:08pm

    Dan Decker

    7338 posts

    Hi willm,

    Excellent idea!

    Thanks for sharing your find of Dynamo as well!

    Is there anything else I can assist you with?

    Cheers,

  • #6 / May 22, 2012 5:26am

    willm

    30 posts

    No that’s fine thanks Dan. Thanks for your help!

  • #7 / May 24, 2012 5:47pm

    Dan Decker

    7338 posts

    Hi willm,

    Fantastic!

    If you need anything else, just let us know.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases