BuddyDev

Search

[Resolved] Mediapress – Media loop instead gallery loop

  • Participant
    Level: Initiated
    Posts: 19
    Piotr on #2669

    Hi guys. I want to list all media items on specific page – just like gallery. I was trying override index.php, and then made loop-media.php (and direct to it). But when i change in this file function “mpp_have_galleries()” to “mpp_have_media()” i get false and nothing is displayed.

    For now i use a halfmeasure. Put in index shortcode [mpp-list-media]. But of course i get media item with filter for galleries above. So its not a solution for mem

    Do you know way i could edit loop/functions to get list of all media?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #2670

    Hi Piotr,
    the mpp_have_galleries() and mpp_have_media() work with global queries.

    What you are trying to do is create a custom loop where mpp media query may not be initilized.

    What I recommend is using custom mpp media query like this

    https://buddydev.com/mediapress/topics/api-reference/core/mpp_media_query/

    And here is the list of Media Template tags( or you can copy it from any of those loops included)
    https://buddydev.com/mediapress/guides/api-reference/template-tags/media-template-tags/

    Are you trying to override some MediaPress specific page or just create a new page to list media. There are shortcodes available too like the below
    https://buddydev.com/mediapress/topics/getting-started/shortcodes/mpp-list-media/

    That you can use.

    Hope that helps. Please do let me know if you need further help.

    Thank you
    Brajesh

    PS: Please make sure to keep the overrides in your theme.

  • Participant
    Level: Initiated
    Posts: 19
    Piotr on #2671

    Hi Brajesh,

    Thank you for your reply. I used custom mpp media query but get response “No media found”. I used that query just below shortcode – list from shortcode has beed displayed bud custom query doesn’t.

    I’m trying to create copy of loop-gallery.php (named loop-media.php) and edit it to display media instead gallery. But like i wrote before – i get “false” from first function: “mpp_have_media()” so no media items are displayed. And yes i do this in my custom template. I’m leaving alone core plugin files.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #2673

    Hi Piotr,

    That is correct because you are not passing the component/component id.
    Try this code

    
    <?php
    $mppq = new MPP_Media_Query( array(
    	//'gallery_id' => mpp_get_current_gallery_id(),
    	'component' => 'members',
    	'component_id' => bp_displayed_user_id()
    ) );
    ?>
    <?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'>
    			<a href="<?php mpp_media_src('full') ;?>" class="mpp-item-thumbnail mpp-media-thumbnail mpp-photo-thumbnail">
    				<img src="<?php mpp_media_src('thumbnail') ;?>" />
    			</a>
    		</div>
    
    		<div class="mpp-item-actions mpp-media-actions mpp-photo-actions">
    			<?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;?>
    
    

    Here we are saying that list all the media from displayed user. Please let me know if this works for you or not?

    • This reply was modified 8 years, 9 months ago by Brajesh Singh.
    • This reply was modified 8 years, 9 months ago by Brajesh Singh. Reason: Correcting endif
  • Participant
    Level: Initiated
    Posts: 19
    Piotr on #2677

    Yes, it’s working. Thank you! 🙂

    Now i need to change filters above in index.php.

    Is there some function or shortcode to create filters for generating list navigation?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #2678

    Thank you for confirming.

    Can you please put a screenshot to show me what filters you are trying to change? I will be able to help in a better way then.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 19
    Piotr on #2679

    This is what i need to change:
    http://i63.tinypic.com/2i24gft.png

    And this is code in index.php i think it have to be edited:

    <div class="item-list-tabs" role="navigation">

      <li class="selected" id="mpp-all">
      pages->mediapress->id ); ?>"><?php printf( __( 'All Media <span>%s</span>', 'mediapress' ), mpp_get_total_media_count() ) ?>

      <?php do_action( 'mpp_directory_types' ) ?>
      <li id="mpp-order-select" class="last filter">
      <?php _e( 'Filter By:', 'mediapress' ) ?>
      <select>
      <option value=""><?php _e( 'All Galleries', 'mediapress' ) ?></option>
      <?php $active_types = mpp_get_active_types(); ?>
      <?php foreach( $active_types as $type => $type_object ):?>
      <option value="<?php echo $type;?>"><?php echo $type_object->get_label();?> </option>
      <?php endforeach;?>
      <?php do_action( 'mpp_gallery_directory_order_options' ) ?>
      </select>

    </div><!-- .item-list-tabs -->

    • This reply was modified 8 years, 9 months ago by Piotr.
    • This reply was modified 8 years, 9 months ago by Piotr.
    • This reply was modified 8 years, 9 months ago by Piotr.
  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #2683

    Hi Piotr,
    Thank you. I see it better now. It is the directory page that you are trying to modify.

    1. If possible, I will advise to revert the old changes as that will affect the User profile Galleries listing too. We should not do that.

    2. Now, since it is directory page, we have two options

    a) Override the gallery directory template.

    b) or Create a custom page template and use that

    Let us see how it works for (a)

    Step 1: Copy mediapress/templates/mediapress/default/buddypress/directory/index.php to yourtheme(orchildtheme)/mediapress/default/buddypress/directory/index.php

    Step 2:- Let us create a file called photo-loop.php in the same directory and paste the code from my previous reply

    Step 3: Change this line

    
    			<?php
    				mpp_get_template( 'gallery/loop-gallery.php' );
    			?>
    

    to

    
    			<?php
    				mpp_get_template( 'buddypress/directory/loop-photo.php' );
    			?>
    

    That’s all. You can remove the unwanted links/drodowns as you deem fit.

    If you want to have both the media and gallery directory, in that case you should not use the above approach. You can use page template to do that. Let us see an example here

    Step 1:- Create a page template by copying your page.php and name that template “Media Directory”

    A page template is created by adding a meta like this to the file

    
    <?php
    /**
     * Template Name: Media Directory
     */
    ?>
    

    Now, we can open our custom page template file and where you see the code to display entry, replace that by the custom loop from my previous reply

    Step2: Visit Dashboard ->Add New Page and select that template and that’s it.

    Strategy 3:- Using shortcode to list Media
    Create/Edit a page and use the following shortcode
    [mpp-list-media type=’photo’ component=’members’ status=’public’]

    That will list all public photos from users

    Now, coming to the 2nd part of your question, is there some code to generate filter? I am sorry, but it is not present yet. I will add it in version 1.1 (Media directory is coming as part of 1.1)

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #2844

    Marking this thread as closed due to lack of replies and I feel the last post clarifies about template structure.

The topic ‘ [Resolved] Mediapress – Media loop instead gallery loop’ is closed to new replies.

This topic is: resolved