[Resolved] Block elements just don’t like BP pages

Home Forums Support [Resolved] Block elements just don’t like BP pages

Home Forums Support Block elements just don’t like BP pages

Viewing 15 posts - 1 through 15 (of 27 total)
  • Author
    Posts
  • #1492541
    Carsten

    I thought this was solved, but it’s not, Block element content is not displayed on BuddyPress pages, this time the Activity page.

    View post on imgur.com

    Thanks for looking into this.

    #1492964
    David
    Staff
    Customer Support

    Hi there,

    where can i see the Activity page ?

    #1493097
    Carsten

    Hi there, the activity page is the landing page when you login.

    Thanks

    #1493102
    David
    Staff
    Customer Support

    So i am seeing the ‘secondary’ container with the Visits and Messages elements in the secondary nav …. whats missing?

    #1493106
    Carsten

    This Block element, containing a WooCommerce block

    View post on imgur.com

    #1493108
    Carsten

    If I change the location to entire site it will show up

    #1493135
    David
    Staff
    Customer Support

    I am seeing another body class of directory on that page. Is Directory a location option in the elements ?

    #1493494
    Carsten

    I’m not sure what you mean?

    View post on imgur.com

    #1493880
    David
    Staff
    Customer Support

    In the Body classes you can see before activity – which is the page slug you’re currently using there is the directory class – In the Element > Display Rules – is Directory a location eg. Directory > Activity or Pages > Directory for example.

    #1495522
    Carsten

    Hi there, can’t tell how and why this directory appears, here are the locations I have set for the element, the block is outputted on Search and Start, but not on https://domain/activity/

    View post on imgur.com

    Thanks

    #1496135
    Tom
    Lead Developer
    Lead Developer

    It’s possible that the BP pages don’t think they’re static pages, so those rules wouldn’t work.

    What David is saying is when you look through the Display Rules, do you see any rules that reference Directory?

    When you say you thought this was solved – what steps were taken to solve it in the first place?

    #1496216
    Carsten

    Hi there, I have earlier posted a topic about elements not working with BP pages, at that time, it was the /register page which was the problem. At that time you said it was something you would look into, if there was an easy solution.

    Makes sense, I don’t believe BuddyPress uses conventional WordPress conditions (as funny as that is), so our Display Rules aren’t aware of their specific conditions/rules when it comes to displaying.

    We’ll see if it’s something easy enough to add compatibility with.

    https://generatepress.com/forums/topic/block-element-is-not-displaying/

    Therefore I waited for a solution, but of course, I could not expect it to be solved.

    The pages /register and /activity are listed in the element, so I expected the block element to work in these pages.

    Regards
    Carsten

    #1497366
    Tom
    Lead Developer
    Lead Developer

    Ah, it’s as I said – BP isn’t using the conventional conditions.

    You’ll have to do this:

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        if ( 123 === $element_id ) {
            if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
                return true;
            }
        }
    
        return $display;
    }, 10, 2 );

    Then you just need to update 123 with the ID of the Element and it should work.

    #1497456
    Carsten

    Hi there, thanks for bringing up a solution.

    Apparently the code is not working, using the post=42208, which I assume is the id of the element.

    I inserted this into the code snippet and added it to my functions.php file, any idea why it should not work with the /activity page?

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        if ( 42208 === $element_id ) {
            if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
                return true;
            }
        }
    
        return $display;
    }, 10, 2 );
    

    Thanks!

    #1497646
    Tom
    Lead Developer
    Lead Developer

    Hmm, instead of this:

    if ( 42208 === $element_id ) {

    Try this:

    if ( 42208 === (int) $element_id ) {

    Any difference?

Viewing 15 posts - 1 through 15 (of 27 total)
  • You must be logged in to reply to this topic.