I’m in a position where I need to use dynamic data as a variable to call dynamic data. Something like this.
{echo:function1(echo{(function2)})}
I have searched and found several people with similar issues, but no answers. Is this even possible? If not, is there a way to use a code block above where I’m trying to use this to insert a PHP variable in place of the second echo?
i think there are situations where using dynamic tags as arguments reliably fails. One situation was if needing to output integers as arguments, there are maybe more situations that fail. idk. I’ve never seen echo being used inside echo before,.
If you post more of what the functions do, or a simplified example to show the point, I expect there’s likely a simpler way of doing what you’re trying to do. it can probably be all inside one function. Generally, it’s best to do all the complicated stuff outside of Bricks, and just use the echo tag to echo the end result.
Sure. I have a custom query loop with a function that lets you display the data found in the query loop. It works great. I’m using it to query a DB table outside Wordpress that holds some user directory information. I have a need to use a user_id found in that table to find a photo in a different query loop. So, what I need to do is use one echo function as the variable in another.
{ echo:function1( echo{ ( function2 ) } ) }
Specifically, I’m trying to do this inside the image address field, but I also tried it in a simple text field and it simply outputs the inner echo statement.
I have worked around it by using a code block and writing the PHP to do the same thing, but that’s a messy way to go. Since I’ve seen a number of posts about the same thing, it feels like nested echo functions should be a thing.
I think my choice would be to have one function, something like this… in functions.php
function my_function($what_function) {
// stuff to get $the_data
if ( $what_function = 'ID_Please' ) {
return $the_data;
}
if ( $what_function = 'Image_Please' ) {
// use $the_data->$user_id to get image
return $the_image;
}
Then simply {echo:myfunction(ID_Please)} in one and Image_Please in the other.
Thanks @digismith. I did something similar to work around it. Basically just wrote the code into a single function. It just seems like this should be something Bricks does.