Sage w/ Blade and Ajax Load More (blade code evaluation)

Hi all!
To get infinite scrolling on some projects of mine I often use Ajax Load More via load_template().
It worked like a charm in Sage 8, but now I’m wondering what’s the correct way to get third-party plugins to source partials and views.

On the same topic, before Blade I wrote a catch-all shortcode which allowed me to insert arbitrary pieces of code directly from the WP editor:

/**
 * Shortcode to get arbitary widgets with content
 */
add_shortcode('widgetc', function ($atts, $content) {
    extract($atts);
    ob_start();
    include(locate_template('views/partials/widget-' . $tpl . '.php'));
    return ob_get_clean();
});

Clearly this does not work anymore with Blade templates, so what’s the correct way to achieve a similar result?

Many thanks!
C.

I had success loading blade templates with something that could look like this :

ob_start();
echo \App\template('partials.widget-' . $tpl);
return ob_get_clean();
2 Likes

Thank you, the same code works wonderfully as an ALM template.
I still have an issue because within Sage ALM fails to include its JS:

The alm_render_shortcode function is being called before the wp_enqueue_scripts, so the wp_enqueue_script('ajax-load-more') comes before registering the script itself.
If I manually add
if (is_home() || is_category()) { // Enqueue core Ajax Load More JS wp_enqueue_script('ajax-load-more'); wp_enqueue_script('ajax-load-more-seo'); }
in my own enqueue function, ALM works again.
Any hint?

PS: I’m giving the same feedback to ALM author, too: https://wordpress.org/support/topic/no-posts-are-loaded/#post-9165527

Did you ever find a solution for this? Experiencing the same issue currently. I figured out to enqueue the script manually, which is now loading the JavaScript I need. However, despite an Ajax request being fired off now, the response is never appended to the page.