Tagged: ajax, Layout Builder
-
AuthorPosts
-
April 23, 2019 at 4:48 pm #1093694
Hi Kriesi,
since one of the latest updates of Enfold, Layout Builder Shortcodes are not working for AJAX loaded content.
We have a page where Layout Builder Page contents from a custom post type are inserted into the page as a type of breaker elements.There is no fancy code in here, the page content of this breaker element page is prepared in an object that holds the content and for output purpose, the_content filter is applied:
echo apply_filters('the_content', $breakerElement->getContent());
This works well, but there are some AJAX features which trigger reloading of the content (this breakers separate some blog posts i.e., sorting is available with ajax).
Now the exact same code is processed at the AJAX endpoint and returns the HTML thats inserted into a wrapping container.
It all worked perfectly since one of the last enfold updates, now the Layout Builder contents of the breaker elements are not returning the correct rendered HTML.For example:
A simple test breaker renders initially correct for a full width layout element with test text inside as HTML<div class="flex_column av_one_full flex_column_div av-zero-column-padding first " style="border-radius:0px; "><section class="av_textblock_section " itemscope="itemscope" itemtype="https://schema.org/CreativeWork"><div class="avia_textblock " itemprop="text"><p>This is some test.</p> </div></section></div>
The same layout builder code renders following with the apply_filters the_content in AJAX calls:
[av_one_full first min_height='' vertical_alignment='' space='' custom_margin='' margin='0px' row_boxshadow='' row_boxshadow_color='' row_boxshadow_width='10' link='' linktarget='' link_hover='' padding='0px' highlight='' highlight_size='' border='' border_color='' radius='0px' column_boxshadow='' column_boxshadow_color='' column_boxshadow_width='10' background='bg_color' background_color='' background_gradient_color1='' background_gradient_color2='' background_gradient_direction='vertical' src='' background_position='top left' background_repeat='no-repeat' animation='' mobile_breaking='' mobile_display='' av_uid='']
At both points, the contents of the custom post type contents are identically, it seems there is some problem with enfolds filters hooked to the the_content filter.
Tried it with using do_shortcode instead, but this also does just work on the initial page view, not for AJAX loaded content.I hope the problem is clearly described and someone can help, thanks.
- This topic was modified 5 years, 7 months ago by Netzdenke. Reason: grammar
April 29, 2019 at 3:40 am #1095153Hey Netzdenke,
Thank you for using Enfold.
You may need to compile the content first and rebuild the shortcode tree for that post. This can be done using a native function from the builder. Example of that code can be found here.
// https://kriesi.at/support/topic/blog-posts-16/#post-1042867
Fetch the post and then compile it using the following function.
$post = get_post( $the_id ); $content = Avia_Builder()->compile_post_content( $post );
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.