WAIT: JavaScript Interaction Argument {echo:php_function} Not Working

Browser: Edge 129
OS: Windows
URL: N/A
Video: N/A

Hello, I am trying to pass dynamic data using {echo} to a JavaScript function using the Bricks interaction argument feature.

Passing the {post_title} works fine, but trying to pass a value using the {echo} dynamic data feature doesn’t work. Console.log shows the arguments passed using the {echo} function as null.

In the screenshot I have changed the name of the function for OPSEC purposes, but the function is used in different areas of the page in working on the page in Rich Text modules. The function returns a related post_id. I’ve added the function name to the “bricks/code/echo_function_names” hook as well.

Thanks in advance!

Jacob Hill

Hello,

thank you for your post. Sadly, I can not replicate your issue. I believe I’ve created the same setup as yours, but please double check:

I have a button, and I’ve set the same {echo:custom_function('aaa', 'bbb')} function as a Button content and as a JS function parameter.

In the Interaction, I’m calling JS function named myCall, that basically just outouts to console and returns whatever the parameter was:

function myCall(data = "Empty"){
    console.log(data);
    return data;
}

And on the PHP side, the custom_function looks like this:

function custom_function($first=null, $second=null)
{
    $message = "Input was:  {$first} {$second}";
    return $message;
}

So, do you see any difference? Can you try with my setup, does it work for you?

Thank you,
Matej

1 Like

Thank you for your response! This is a Bricks Builder Extras element, so I’m assuming that it is a bug with that element. I did try adding your simple PHP function, and it still didn’t output.

This can be closed out. Thanks again for the help!

Jacob Hill