• Resolved Wolfram Kl?ger

    (@wolframhk)


    Hey Lyte ??

    David from GeneratePress Support got me to contact you.

    The question is, why is WP Lyte working on a paginated archive, why is it not on an infinitely scrolling archive page?

    Link to my page is above.

    Here is the link to my chat with the GP Support Team:

    https://generatepress.com/forums/topic/block-content-template-location-homepage/

    The Lyte calling snippet is

    add_shortcode( 'featured_youtube_video', function() {
        ob_start();
        // Start your PHP below
    	// ACF(featured_youtube_id, post_id)
        $youtube_id = get_field('featured_youtube_id', get_the_ID());
    	if( $youtube_id ) {
    		// WP Youtube Lyte
    		echo do_shortcode('[lyte id='.$youtube_id.']');
    	}
        // End your PHP above
        return ob_get_clean();
    } );

    I created a GenerateBlocks content template, including the shortcode

    [featured_youtube_video]

    which is calling the snippet, which is getting the video id from an ACF, before finally Lyte can do its thing.

    As described in the forum, everything works fine, until I activate

    Customize > Layout > Blog > Infinite Scroll

    Then only the first featured Youtube preview image is shown. The second, after scroll down, is gray.

    Infinite Scroll de-activated, back to a paginated list, both previews are fine. First on first page, second on second, as expected.

    What’s going wrong here?

    Thanks so much in advance
    Wolfram

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’ll have to have ensure the infinite scroll JS calls ly.te() to render newly added vids and all will be fine Wolfram ??

    hope this helps,
    frank

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    Hey Frank, thanks a lot.

    BUT: infinite scroll is a checkbox. I have no idea, what Tom Usborne does with it, which JS he’s calling ??

    Or did I get you wrong, and you mean

    echo do_shortcode(‘[ly.te id=’.$youtube_id.’]’);

    instead of

    echo do_shortcode(‘[lyte id=’.$youtube_id.’]’);

    in my PHP code snippet, see above?

    (yes, the only difference is that little dot between ly and te ??

    Where / how else could I get access to this call, using GPP & GB?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Or did I get you wrong, and you mean

    no ??

    I’m afraid you’ll have to ask the question to GP; the issue is by default LYTE acts on the onLoad event (or domContentLoaded), but those don’t get triggered when doing infinite scroll, which is why some “glue” is needed to make sure the ly.te() gets called after the infinite scroll JS got more content.

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    Thanks again, I’ll try my very best to convince Tom ??

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Say hi to Tom from me and tell him he can contact me if he needs more info ??

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    I’m sorry. I had no direct contact to Tom. His team finished this topic for now. So I have to fall back to the paginated archive, instead of infinite scroll.

    Without GPP’s Infinite Scrolling, WP Lyte works like a charm. PageSpeed Insights scores 84. That’s not too bad, for vanilla hosting, no cache, just AutOptimize, so far.

    Focussing on my little snippet again: could I further improve the Lyte call?

    To me, it looks slightly over-complicated. But maybe, that’s my PHP allergy ??

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Focussing on my little snippet again: could I further improve the Lyte call?

    To me, it looks slightly over-complicated. But maybe, that’s my PHP allergy ??

    looks OK to me, but do you _need_ those 2 output buffer calls?

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    You mean, unbuffered is good enough, like this?

    add_shortcode( 'featured_youtube_video', function() {
        // ACF(featured_youtube_id, post_id)
        $youtube_id = get_field('featured_youtube_id', get_the_ID());
        if( $youtube_id ) {
            // WP Youtube Lyte
    	echo do_shortcode('[lyte id='.$youtube_id.']');
        }
    } );

    I actually have no idea, what ob_* is doing here. I thought, this is kind of default, and required for such shortcode snippets.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    don’t think it’s needed no, why not give it a quick test? ??

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    Of course ??

    Done!

    Very interesting result: WP Youtube Lyte works as before. You’re awesome, and you know it, I suppose …

    BUT: The GenerateBlock content template gets disturbed. Calling Lyte without ob_*, pushes the video from last to top position.

    The template is basically just a post title, consisting of

    – Kicker (say headline of the headline)
    – Headline
    – Post Meta (Author, Date, Date)
    – Subline (lead text, 1 or 2 lines)
    – Featured Video

    With ob_*, everything as expected.

    Without ob_*, the video pops before the kicker. Everything else is fine.

    Any idea, how I could fix that?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    sure; keep the output buffer calls ??

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    My idea is, I could fix it by CSS.

    But, generally, what’s the benefit of wrapping the call in ob_* ?

    What’s the disadvantage, if I keep the buffer calls for proper sequence?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    the disadvantage is kind of theoretical; output buffer is very powerful, but one small mistake in the code can have ugly consquences. if it works OK, there’s no reason to change it ??

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    Thank you so much, until next!

    Thread Starter Wolfram Kl?ger

    (@wolframhk)

    ahem, just to mark this resolved ??

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Generate Press, Infinite Scroll vs. Paginated’ is closed to new replies.