Site logo

[Support request] Recreate the GP site library grid and filters

Home Forums Support [Support request] Recreate the GP site library grid and filters

Home Forums Support Recreate the GP site library grid and filters

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1800796
    George

    I really like how the GP site library works with the Ajax filtering at the top and the preview popup.
    https://generatepress.com/site-library/

    I imagine this is a custom solution? Could this be applied to archives?

    #1801772
    Tom
    Lead Developer
    Lead Developer

    Hey George,

    Yes, this is a super simple custom solution built specifically for the library.

    Basically, each box has a unique class with its category slug.

    Then, each button has a data-* attribute with the category slug attached to it.

    Then the JS is quite simple:

    $( '.page-builder-group .builder-links a' ).on( 'click', function( e ) {
        e.preventDefault();
    
        var _this = $( this ),
            filter = _this.data( 'filter' );
    
        _this.siblings().removeClass( 'gb-button-primary' ).addClass( 'gb-button-secondary' );
        _this.removeClass( 'gb-button-secondary' ).addClass( 'gb-button-primary' );
    
        if ( '' == filter ) {
            $( '.site-box' ).show();
            $( '.generatepress-sites' ).attr( 'data-page-builder', '' );
        } else {
            $( '.site-box:not(.' + filter + ')' ).hide();
            $( '.site-box.' + filter ).show();
            $( '.generatepress-sites' ).attr( 'data-page-builder', '.' + filter );
        }
    } );

    For a more complex setup, something like this would be preferable: https://isotope.metafizzy.co/

    #1801859
    George

    Hmmm, ok, I see, so the thumbs are basically a static grid, not something taken from a custom post type. The preview popup loads an iframe on top, right?

    #1802821
    Tom
    Lead Developer
    Lead Developer

    Exactly – there’s a blank iframe that gets populated with a URL once a site is chosen, and it’s set to display “fixed” on top of the site.

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