NO BUG: Bricks_render_dynamic_data not working?

i’m expecting bricks_render_dynamic_data() render a dynamic_tag inside the $content variable

so "echo bricks_render_dynamic_data(‘My Post Title: {post_title}’); " will be output as “My Post Title: my Title” if my Title is the post title

instead i get My Post Title: {post_title} as output

thx

Simone

Where? In a php template, in a bricks code element, in your own custom function? What’s the surrounding code? I can’t tell anything from the info you’ve given.

I’ve found the problem trying to display a dynamic value inside bricksforge email template tool
after some check on the email code i’ve discover it use bricks_render_dynamic_data ti display dynamic values and done some test with simply code, calling a function inside a bricks element that use the bricks_render_dynamic_data() fuinction and testing as a simpole php sniper in a test page

same result everywhere

for what i can see, bricks_render_dynamic_data() only call the “render_content” function passing the variables to it

the function is

public static function render_content( $content, $post_id = 0, $context = 'text' ) {

	// Return: Content is a flat array (Example: 'user_role' element conditions @since 1.5.6)
	if ( is_array( $content ) && isset( $content[0] ) ) {
		return $content;
	}

	// Support for dynamic data picker and input text (@since 1.5)
	$content = ! empty( $content['name'] ) ? $content['name'] : (string) $content;

	// Return: $content doesn't contain opening DD tag character '{' (@since 1.5)
	if ( strpos( $content, '{' ) === false ) {
		return $content;
	}

	// Strip slashes for DD "echo" function to allow DD preview render in builder (@since 1.5.3)
	if ( strpos( $content, '{echo:' ) !== false ) {
		$content = stripslashes( $content );
	}

	$post_id = empty( $post_id ) ? get_the_ID() : $post_id;
	$post    = get_post( $post_id );

	return apply_filters( 'bricks/dynamic_data/render_content', $content, $post, $context );
}

i can’t figure how it handles the dynamic tag, outside calling the filter, but seems not to happen

maybe i’m wrong thinking the bricks_render_dynamic_data works out of the box and have to be used always applying the ‘bricks/dynamic_data/render_content’ filter?

I’ve not used Bricksforge but from a glance at the docs:

It needs 3 objects.

  1. The string with tags:
'My Post Title: {post_title}' 
  1. The post ID from which to get it. If omitted it’s assumed to be the current post. If when creating the email there is no current post - it will return blank, or error.

  2. Context, which defaults to ‘text’ so should be ok.

So I’d ask Bricksforge what is the current query object when it is at the create email stage. If it’s the form array then Bricks won’t know how to interpret the variable. If it’s a custom post type (the form entry has been saved by this stage), do you need to add get_the_id in your helper to tell it where the post_title is.

post_title is only used as example

  1. i’ve tested with {current_date} and the problem is the same
  2. using post_title outside with no post, I can expect an error or a null / empty value, not the “{post_title}” as output
  3. if I’m not wrong, the bricks_render_dynamic_data can run everywhere, passing the correct parameters to it, if I test with e simple php function calling it, I still get the “unparsed” content as output

for what I can see by the function code, or the function is not intended to parse the dynamic tag, but only to “normalise” the content before the parsing or the function miss something ^^;

Hi @comicscorner,

If I understand correctly, you are trying to render dynamic tags outside of frontend/bricks builder, right?

If yes, then please refer to this post, where it’s explained why this is not working anymore, since 1.9.9: NO BUG: Dynamic data can no longer be read on front-end pages shown in admin - #7 by itchycode

I’ll mark this post as a NO BUG.

Best regards,
M