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.

<select multiple> in combination with {exp:channel:entries dynamic_parameters="..."}

November 05, 2012 3:19pm

Subscribe [1]
  • #1 / Nov 05, 2012 3:19pm

    Komtur

    15 posts

    My HTML Code looks like this:

    ...
    <select class="material tags" name="search:material_tag" data-placeholder="Tags" tabindex="4" multiple>
     <option value="not IS_EMPTY">all</option>
    {exp:tag:cloud channel="material" most_popular="100"}
     <option value="{tag}">{tag}</option>
    {/exp:tag:cloud}
    </select>...

    So I got a multiple select here.
    You can ignore the exp:tag:cloud tag, since the problem also occures with an undynamic set of tags.

    The “dynamic_parameters” on the other hand gives me the search on the custom field that I need:

    {exp:channel:entries channel="material"
     dynamic_parameters="search:material_tag"
     orderby="date" sort="desc" limit="10"}
    ...code here…
    {/exp:channel:entries}

    But the search only passes me the last parameter of my input and the search fails.

    I tried to use:

    name="search:material_tag[]"

    and

    dynamic_parameters="search:material_tag[]

    instead.

    Without any effect.

    Anyone any idea?

  • #2 / Nov 05, 2012 3:30pm

    Komtur

    15 posts

    With the “output profiler” turned on I can see the paramaters are correct:


    POST DATA
    <pre><code> 
    $_POST[‘search:material_tag’] 
    Array
    (
      [0] => tag1
      [1] => tag2
    )<pre><code>

    But still unsuccessfull with the search

  • #3 / Nov 06, 2012 5:38pm

    Robin Sowell

    13255 posts

    Hi Komtur,

    The dynamic parameters don’t support multi-selects (basically, they don’t support arrays in the post value).  Just brainstorming…..

    If you turn php parsing ‘on’ and redefine your post:

    <?php
    
    $_POST['search:material_tag'] = implode('|', $_POST['material_tag']);
    
    ?>

    Note- I renamed the post to avoid conflicts.

    I don’t entirely love this approach, but I suspect it will work.

    Does it make sense what’s going on there?

  • #4 / Nov 13, 2012 5:16am

    Komtur

    15 posts

    This works. Thanx.

  • #5 / Nov 13, 2012 9:35am

    Robin Sowell

    13255 posts

    😉  Thanks for the confirmation.  If you run into any more issues, just let us know!

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

ExpressionEngine News!

#eecms, #events, #releases