1

I have a routine that searches for an existing customer, based on their member email address. I'm passing the email address as an embed variable:

{embed="delivery/charter_customer_form" cust_email="{email}"}

The variable returns the address correctly. If I put {embed:cust_email} in the template, it displays the correct address.

However, when I plug it into the channel entry tag, I get no results, even I though I know for a fact that there is a match there:

{exp:channel:entries channel="customers" search:customer_email="{embed:cust_email}" dynamic="no" limit="1"}

Also, if I replace the variable with the hard-coded address, it returns the entry I'm looking for.

Am I overlooking something?

3
  • I'd turn on the output profiler and see what the actual query being made looks like (whether the searched value is wrong, empty, or what). Commented Apr 13, 2013 at 1:26
  • Interesting. The tag renders the {email} tag as it was passed to the template: {exp:channel:entries channel="customers" search:customer_email="{email}" dynamic="no" limit="1" parse="outward"}
    – Ty Morton
    Commented Apr 13, 2013 at 3:47
  • Is there something special about that tag that it won't render its value inside of another tag? That was the whole reason I felt the need to pass the variable in an embedded template in the first place.
    – Ty Morton
    Commented Apr 13, 2013 at 3:49

2 Answers 2

1

This is due to ExpressionEngine parsing order in which user defined global variables are parsed at last. See here http://loweblog.com/downloads/ee-parse-order.pdf

To resolve this problem, you need to have small custom plugin which will return member's email. The plugin code would be like:

class Custom_plugin {
    public $return_data;
    function __construct(){
        $this->EE =& get_instance();    
        $this->return_data = $this->EE->session->userdata('email');
    }
}

I hope, you will put other plugin code yourself.

Now you can have embed variable like:

{embed="delivery/charter_customer_form" cust_email="{emp:custom_plugin}"}
2
  • That's the only way to search by a person's email address, is through an external plug-in? That just floors me.
    – Ty Morton
    Commented Apr 13, 2013 at 13:58
  • You can try other solution via either Stash (github.com/croxton/Stash/tree/dev) or Low Variables (gotolow.com/addons/low-variables). These module would work for this purpose. I did preferred using the plugin for this purpose as it seemed me quick and easy :) ..... Commented Apr 13, 2013 at 14:13
0

You might need parse="inward" on your channel entries tag.

8
  • Nope. parse="inward" makes no difference on module tags - only plugin tags, and only when that plugin tag is being used as a tag pair. Commented Apr 13, 2013 at 1:23
  • You sure about that? Here's an example of Mark Croxton recommending the exact same thing when using a Stash variable as a search parameter: devot-ee.com/add-ons/support/stash/viewthread/7531#25711
    – Tyssen
    Commented Apr 13, 2013 at 2:39
  • And here's a thread on the EE forums discussing using it on weblog/channel entries too: ellislab.com/forums/viewthread/55771
    – Tyssen
    Commented Apr 13, 2013 at 2:47
  • That did not solve the problem.
    – Ty Morton
    Commented Apr 13, 2013 at 3:13
  • That's cool, just the first thing to check. Try switching cust_email="{email}" to cust_email="{logged_in_email}" in your embed variable declaration. Any difference there?
    – Ian Young
    Commented Apr 13, 2013 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.