WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
[resolved] Random Images on paginated pages (19 posts)

  1. Fill in the Blank
    Member
    Posted 4 years ago #

    So I have implemented the random images onto my sidebar on m own (I didn't want to use the widget because I wanted it to just do one thing all the time and not give my client the capability to modify it.

    So in my own sidebar.php I used the following code:
    <?php if (function_exists("nggShowRandomRecent")) {echo nggShowRandomRecent('random',6,'home');} ?>

    This works well and I utilize my own theme that looks like this:

    <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    <ul>
      <?php //echo "images is ".print_r($images); ?>
    	<?php foreach ( $images as $image ) : ?>
    	<li><a href="<?php echo $image->pagelink; ?>" title="<?php echo $image->alttext ?>" ><?php if ( !$image->hidden ) { ?><img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" width="74" height="74" /><?php } ?></a></li>
    	<?php if ( $image->hidden ) continue; endforeach; ?>
    </ul>
    <?php endif; ?>

    the <?php echo $image->pagelink; ?> works if you mod nggfunctions.php with this:
    $picturelist[$key]->pagelink = get_permalink( $picture->pageid );
    around line 358
    and that allows me to show a link for the page associated to the gallery the images are associated with.

    My only issue I have now is that if I go to a page that displays a gallery's images and I click to page 2 of the pagination then the nggShowRandomRecent will go to my theme and only print

    I have print_r the $picturelist array that goes into nggCreateGallery and it looks fine,b ut it won't come out the other end of that function... the only thing I see different is that the url at top has ?nggpage=2 in it. And no matter is I unset($nggpage) before entering nggShowRandomRecent it breaks...

    Any help would be great... if not then I understand *kicks a can down the block*

    Oh and I commented out:

    if ( $pageid == get_the_ID() || !is_home() )
            if (!empty( $pid ))  {
                foreach ($picturelist as $picture) {
                    $picarray[] = $picture->pid;
                }
                $out = nggCreateImageBrowser($picarray);
                return $out;
            }

    in nggShowRandomRecent because sometimes it would invoke it in nggpage=3 or so. Very weird issue and if I dig for another 3 days I might find it ;)

  2. Fill in the Blank
    Member
    Posted 4 years ago #

    bump

  3. Alex Rabe
    Member
    Posted 4 years ago #

    can you give me a link as demo ?

  4. Fill in the Blank
    Member
    Posted 4 years ago #

    sure Alex... I need to take it out of maintenance mode... let me know when you are able to review

  5. Fill in the Blank
    Member
    Posted 4 years ago #

    go ahead and view it here:
    http://www.sounds-like.org/blog

  6. Fill in the Blank
    Member
    Posted 4 years ago #

    bump

  7. Alex Rabe
    Member
    Posted 4 years ago #

    So in the case you add : ?nggpage=2 , the function nggCreateGallery() return two times a content in $out (main gallery & random widget) ?

  8. Fill in the Blank
    Member
    Posted 4 years ago #

    when you go to http://sounds-like.org/blog/gallery-m-a-n-d-y-album-tour/?nggpage=2 the call to <?php if (function_exists("nggShowRandomRecent")) {echo nggShowRandomRecent('random',6,'home');} ?> only provides the following in the GALLERY section of the sidebar:

    <ul>
    </ul>

    from my template page that looks like this:

    <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    <ul>
      <?php //echo "images is ".print_r($images); ?>
    	<?php foreach ( $images as $image ) : ?>
    	<li><a href="<?php echo $image->pagelink; ?>" title="<?php echo $image->alttext ?>" ><?php if ( !$image->hidden ) { ?><img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" width="74" height="74" /><?php } ?></a></li>
    	<?php if ( $image->hidden ) continue; endforeach; ?>
    </ul>
    <?php endif; ?>

    I guess I am not sure what you are asking...

  9. Alex Rabe
    Member
    Posted 4 years ago #

    Go to nggfunctions.php and look into nggCreateGallery(); check the $out before it returns with var_dump()

  10. Fill in the Blank
    Member
    Posted 4 years ago #

    ahhh ok...

  11. Fill in the Blank
    Member
    Posted 4 years ago #

    tried to print_r it before '$out = apply_filters('ngg_gallery_output', $out, $picturelist);' after '$out = nggGallery::capture ( $filename, array ('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation, 'current' => $current_pid, 'next' => $next, 'prev' => $prev) );'

    I get nothing.

  12. Fill in the Blank
    Member
    Posted 4 years ago #

    I might not have performed that well... ;)

  13. Alex Rabe
    Member
    Posted 4 years ago #

    Then check before $out = nggGallery::capture ...
    if you have a picture array or not : var_dump($picturelist), if this empty check the array before the pagination cut the array (line 288)

  14. Fill in the Blank
    Member
    Posted 4 years ago #

    ok

    using var_dump (instead of print_r) before:
    $out = apply_filters('ngg_gallery_output', $out, $picturelist);

    results in:
    string(14) " "

    before:
    $out = nggGallery::capture ( $filename, array ('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation, 'current' => $current_pid, 'next' => $next, 'prev' => $prev) );

    results:
    NULL

    before pagination var_dump($picturelist); gives us the (what seems to be) the proper array.

  15. Alex Rabe
    Member
    Posted 4 years ago #

    Sorry my mistake, check before $out = nggGallery::capture... var_dump($picturelist); this should contain the array

  16. Fill in the Blank
    Member
    Posted 4 years ago #

    oh ha...

    array(0) { }

    that is what it gives me

  17. Alex Rabe
    Member
    Posted 4 years ago #

    If the array is correct before line 288, and empty after line 314, it's probably something around the pagination which causes the problem. Need to look deeper here, close my work today...

  18. Fill in the Blank
    Member
    Posted 4 years ago #

    all good Alex. I appreciate you looking into it. If there is a better way for me to do this then I would not mind modifying it. Thank you again. I might program a work around for myself. But I thank you... I will have to donate some $... I will search that out later.

  19. Fill in the Blank
    Member
    Posted 4 years ago #

    I just did some custom stuff

    in nggShowRandomRecent function I changed this "around" line 1068:
    from

    if ( is_array($picturelist) )
            $out = nggCreateGallery($picturelist, false, $template);

    to

    if ( is_array($picturelist) )
            $out = nggCreateGallery($picturelist, false, $template, false, true);

    AND around line 225
    from

    function nggCreateGallery($picturelist, $galleryID = false, $template = '', $images = false) {

    to

    function nggCreateGallery($picturelist, $galleryID = false, $template = '', $images = false, $nopagination = false) {

    AND finally around line 290
    from

    if ( !is_home() || $pageid == $current_page )

    to

    if ( (!is_home() || $pageid == $current_page) && !$nopagination )

    it works... and I am happy... but cannot update :P and that is fine with me for now.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.