• Resolved djdobro

    (@djdobro)


    Basically what I want to do, at least until the Album feature is Opened, is to have a page called Album. It should have children pages, associated with FooGalleries. Now when I get all the children and loop them, I want to be able to get the Gallery Thumb, (I already have the link from the page its self), Title and that is a good start.
    So is there a method to get the gallery, associated to a page? I know i can get all galleries with foogallery_get_all_galleries() but that may not be the perfect solution.
    On a side note, Love the plugin, really well built. I plan to make a few extensions for the most famous LightBox scripts when I have more time.

    https://wordpress.org/plugins/foogallery/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ola, você conseguiu a solução estou com o mesmo problema?

    Hello, you got the solution I am having the same problem?

    Hi guys, I just wanted to jump in here and let you know that we are really close to releasing Albums for FooGallery.

    I’ll have to check with the team for a more exact timeline, but we’ve been testing a beta version with just a few more tweaks needed before releasing.

    Thread Starter djdobro

    (@djdobro)

    Great to hear that. I really like the simplicity of the gallery, yet the code behind it is really well written.
    I actually managed to do something, here is my code:

    $gal = foogallery_get_all_galleries();
                $args = array(
                    'width'  => 245,
                    'height' => 156,
                    'crop'   => true,
                );
                foreach ($gal as $g) {
                    $usages = $g->find_usages();
                    $src = apply_filters('foogallery_attachment_resize_thumbnail', $g->featured_image_src('full'), $args, $g);
                    ?>
                    <li>
                        <a href="<?php echo get_the_permalink($usages[0]) ?>">
                            <img src="<?php echo $src ?>"/>
    
                            <div class="hover_overlay">
                                <div class="centered">
                                    <span class="name"><?php echo $g->name ?></span>
                                    <span class="line"></span>
                                    <span
                                        class="description"><?php echo $g->settings['masonry-direction-hover_description'] ?></span>
                                </div>
                            </div>
                        </a>
                    </li>
                <?php
                }
                ?>

    So basically i get all the galleries and get their first attached page. After that its easy to understand. If I can help with testing the albums, I will be happy to.
    As I said, it is extremely easy to make extensions and what not, real pleasure to work with the plugin.

    Very cool, and thanks for the kind words. I can’t take any of the development credit though, that goes to Co-founder and Lead Developer @bradvin 🙂

    We would love to see what you come up with in the way of extensions and would be happy to help possibly promote them within the plugin itself and on our page here:
    http://foo.gallery/extensions/

    p.s. Keep in mind that paid extension development is also welcome and depending on it’s functionality, might also be applicable for our vendor program at http://fooplugins.com

    I’m solution:

    Create new function in my project:

    /**
    * Returns all FooGallery galleries
    *
    * @return FooGallery[] array of FooGallery galleries
    */
    function foogallery_get_featured_galleries( $slug = ‘default’ ) {
    $gallery_posts = get_posts(
    array(
    ‘post_type’ => FOOGALLERY_CPT_GALLERY,
    ‘post_status’ => ‘any’,
    ‘cache_results’ => false,
    ‘nopaging’ => true,
    )
    );

    if ( empty( $gallery_posts ) ) {
    return false;
    }

    $galleries = array();

    foreach ( $gallery_posts as $post ) {

    $meta_values = get_post_meta( $post->ID, ‘foogallery_settings’, true );

    if ( $slug == $meta_values[‘oneimage_featured_slug’] )
    $galleries[] = FooGallery::get( $post );
    else if ( $slug == ‘default’ )
    $galleries[] = FooGallery::get( $post );
    }

    return $galleries;
    }

    Slug is propriety on select gallery show homepage;

    Example:
    http://noticias.carsale.uol.com.br/salao-sao-paulo/

    Thread Starter djdobro

    (@djdobro)

    This is what I just did. Basically have a page that is the Album and this will be its Template page. Everything you need is in the FooGallery Class. Here i just take all children of the Album, then take their foogallery attachment, which is saved by a metabox and call on the Gallery Class. Easy as that.

    <?php
    /**
     * Template Name: Album Template
     */
    
    $args = array(
    	'post_parent' => get_the_id(),
    	'post_type'   => 'any',
    	'posts_per_page' => -1,
    	'post_status' => 'any' ); 
    
    $attachments = get_children( $args );
    
    	if ( $attachments ) {
    		foreach ( $attachments as $attachment ) {
    			$meta = get_post_meta( $attachment->ID,'_foogallery', true);
    			$gal = FooGallery::get_by_id($meta);
    			echo $gal->featured_image_html(); //Features Image of the Gallery
    			echo $gal->image_count(); //Total images in the Gallery
    			 echo get_the_permalink($attachment); // the Link to the Page containing the Gallery
                             //Rest of your code goes here
    		}
    	}

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display all galleries on page children’ is closed to new replies.