BuddyDev

Search

Custom gallery and media Search on buddypress/directory template

Tagged: 

  • Participant
    Level: Initiated
    Posts: 4
    Nash on #8797

    Hi, I was after some example code to implement a custom search page, searching on name, description from a search box with maybe tabs for the different order types. The search on the current directory does not seem to work? I have set up my files in my child theme to begin on this but am struggling to put it all together on one page. It would be great to have some example code that I can build on please?
    Thanks in advance
    Nash

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #8803

    Hi Nash,
    Welcome to BuddyDev.

    Thank you for posting. It is easily doable. all you need to do is modify our main query loop.

    To change the main loop, you can uise the following filter

    https://github.com/buddydev/mediapress/blob/master/mpp-core-component.php#L421

    And the ajax loading on directory is done by this

    https://github.com/buddydev/mediapress/blob/master/core/ajax/mpp-ajax.php#L72

    MediaPress MPP_Gallery_Query allows you to search in the same way you can do with WP_Query. All you need to do is pass the proper args.

    Hope that helps.

  • Participant
    Level: Initiated
    Posts: 4
    Nash on #8943

    Hi,

    Thanks for the information. I have set up my custom search with a custom search form too but have a couple of questions. I have a custom media-loop.php which is called from my custom index.php (all in my child theme mediapress/default/buddypress/directory folder). I would like to show the media in a pop up lightbox from this page, I could accomplish this using the shortcode <?php echo do_shortcode(‘[mpp-list-media search_terms=”” column=6 per_page=30]’); ?> but this doesn’t include the title of the media or pdf or word documents (doc type) do not open in a lightbox? Ideally I would like to display all doc and photos in a lightbox when clicked. Please could you provide a code example of this.
    My media-loop.php code looks like this:

    <?php
    // Exit if the file is accessed directly over web
    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }
    /*$type = $_GET[‘type’];
    echo $type;*/
    $search_terms = $_GET[‘search_terms’];
    //echo $_GET[‘search_terms’];
    //$type = isset( $_POST[‘filter’] ) ? $_POST[‘filter’] : ”;

    //echo $_GET[‘filter’];
    $type = $_GET[‘filter’];
    //echo ‘filter’;
    //echo $_GET[‘filter’];
    //echo $type;

    /**
    * List all galleries for the current component
    *
    */
    ?>

    <?php
    $mppq = new MPP_Media_Query( array(
    //’gallery_id’ => mpp_get_current_gallery_id(),
    ‘component’ => ‘members’,
    ‘type’ => $type,
    ‘page’ => $page,
    ‘search_terms’ => $search_terms
    ) );
    ?>
    <?php if( $mppq->have_media() ): ?>
    <?php while( $mppq->have_media() ): $mppq->the_media(); ?>

    <div class=”mpp-u <?php mpp_media_class( mpp_get_media_grid_column_class() );?>”>

    <?php do_action( ‘mpp_before_media_item’ ); ?>

    <div class=’mpp-item-entry mpp-media-entry mpp-photo-entry’>
    ” class=”mpp-item-thumbnail mpp-media-thumbnail mpp-photo-thumbnail”>
    ” />

    </div>

    <div class=”mpp-item-actions mpp-media-actions mpp-photo-actions”>
    ” class=”mpp-gallery-title”><?php mpp_media_title(); ?>
    <!–<?php mpp_media_action_links();?>–>
    </div>

    <?php do_action( ‘mpp_after_media_item’ ); ?>
    </div>

    <?php endwhile; ?>
    <?php
    mpp_reset_media_data();
    mpp_reset_gallery_data();
    ?>

    <?php endif;?>

    <?php echo do_shortcode(‘[mpp-list-media search_terms=”” column=6 per_page=30]’); ?>

  • Participant
    Level: Initiated
    Posts: 4
    Nash on #8945

    Hi, sorry me again:) Also how do I pass pagination parameters to my media query, I would like to have 6 per line and 30 on a page?
    Kind regards
    Nash

  • Participant
    Level: Initiated
    Posts: 4
    Nash on #9009

    Hi, Sorry to be a pain but I have figured out how to do most of the above but have one final question. I have decided to just use the media shortcode to list all media, added the hook ‘mpp_after_media_shortcode_item’ to display the title. I chose to use the shortcode because it has the light box with the ability to comment and rate the media (I have the free addon). The ‘doc type’ does not display the pdf, word document etc in the light box, how can I accomplish this please?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #9012

    Hi Nash,
    I am sorry I could not offer the help in time. I am glad you figured it.

    The problem with lighbox is it needs the media to be displayable/playable.Though It is possible to embed the video player or the doc viewer, we haven’t added the support for it.

    We are using Magnific Popup
    http://dimsemenov.com/plugins/magnific-popup/

    If you see an easy way to do it, please let me know and I will support.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved