EE v2.7.2
Build Date: 20131008

I can't seem to find an elegant solution to make this work.

I've setup a channel name "test" with a field named 'test\_field' (Text Input).
I've created some entries with the test\_field populated the same as entries title.

* apple
* banana
* foo
* bar

The goal is to use the search by parameter field 'test\_field' and return 2 entries - "foo" and "bar".

You can see the Foo Bar plugin here: <https://github.com/surprisehighway/foo_bar>

Attempt 1
---------

The single plugin tag `{exp:foo_bar}` returns the string 'foo|bar'. Looks like the entries tag is parsing before the foo\_bar tag in the SQL query. `LIKE "%{exp:foo\_bar}%"`. That is expected without parse inward?

```
{exp:channel:entries channel="test" dynamic="no" search:test_field="{exp:foo_bar}"}
    <h1>{title}</h1>
{/exp:channel:entries}

SELECT t.entry_id FROM exp_channel_titles AS t
LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON wd.entry_id = t.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1396016523  AND (t.expiration_date = 0 OR t.expiration_date > 1396016523) AND t.channel_id = '11' AND t.status = 'open' AND ( (wd.site_id=1 AND wd.field_id_111  LIKE "%{exp:foo\_bar}%") )ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 100

```

Attempt 2
---------

You would think that parse inward added to the entries tag would fix this. I'm still getting `LIKE "%{exp:foo\_bar}%"` when adding parse="inward" to the entries tag. **This is not expected**

**EDIT**: Should have checked my tweets. Ellislab [said](https://twitter.com/kevincupp/status/449243408071401472) this will be fixed in the next release. I am still stumped with Attempt 5 in the meantime.

```
{exp:channel:entries channel="test" dynamic="no" search:test_field="{exp:foo_bar}" parse="inward"}
    <h1>{title}</h1>
{/exp:channel:entries}

SELECT t.entry_id FROM exp_channel_titles AS t
LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON wd.entry_id = t.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1396016672  AND (t.expiration_date = 0 OR t.expiration_date > 1396016672) AND t.channel_id = '11' AND t.status = 'open' AND ( (wd.site_id=1 AND wd.field_id_111  LIKE "%{exp:foo\_bar}%") )ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 100

```

Attempt 3
---------

Knowing from previous experience, EE's template parser struggles at times when plugin tags that are shoved into parameters. What if we make it a pair tag instead? The input value outputs directly to the foobar\_result variable. We end up with `LIKE "%{foobar\_result}%"` in our SQL query.

The foo\_bar:pair tag is a single row output using the ee()->TMPL->parse\_variables\_row method.

```
{exp:foo_bar:pair input="foo|bar"}
    {exp:channel:entries channel="test" dynamic="no" search:test_field="{foobar_result}"}
        <h1>{title}</h1>
    {/exp:channel:entries}
{/exp:foo_bar:pair}

SELECT t.entry_id FROM exp_channel_titles AS t
LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON wd.entry_id = t.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1396018169  AND (t.expiration_date = 0 OR t.expiration_date > 1396018169) AND t.channel_id = '11' AND t.status = 'open' AND ( (wd.site_id=1 AND wd.field_id_111  LIKE "%{foobar\_result}%") )ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 100

```

Attempt 4
---------

Let's add parse inward to the `{exp:foo_bar:pair}` tag so it's parsed before the entries tag. It works! But...**see Example 5**

```
{exp:foo_bar:pair input="foo|bar" parse="inward"}
    {exp:channel:entries channel="test" dynamic="no" search:test_field="{foobar_result}"}
        <h1>{title}</h1>
    {/exp:channel:entries}
{/exp:foo_bar:pair}

```

Attempt 5
---------

Let's say we purposefully not find an entry result and return what is within the no\_results conditional. My no\_results condition is not working now because the foo\_bar pair tag is returning a result. I need the no\_result conditioning to work for the entries tag.

```
{exp:foo_bar:pair input="find_no_entry" parse="inward"}
    {exp:channel:entries channel="test" dynamic="no" search:test_field="{foobar_result}"}

        {if no_results}
            <h1>No results buddy</h1>
        {/if}

        <h1>{title}</h1>

    {/exp:channel:entries}
{/exp:foo_bar:pair}

```

Fini
----

Stuck at attempt 5 without getting more messy. Preferably without using another plugin.
How do I solve this without getting more convoluted by wrapping it all with Stash? ;)