• Resolved ODAK71

    (@odak71)


    How can I replace

    $gallery = $nggdb->find_gallery($gallery->gid); 
    $picture_data = $wpdb->get_results("SELECT filename, alttext FROM bvcuzxy_ngg_pictures WHERE galleryid=".$galleryid);
            			

    since nggdb ist not usable anymore in NGG 3.5.x

Viewing 2 replies - 1 through 2 (of 2 total)
  • Benjamin

    (@benjaminowens)

    Hi @odak71,

    NextGEN has a newer internal API that is hopefully a little easier to work with. The following snippet will retrieve a gallery from the database:

    $id = 4;
    $gallery_mapper = \Imagely\NGG\DataMappers\Gallery::get_instance();
    $gallery = $gallery_mapper->find($id);

    And to retrieve the images belonging to a gallery:

    $image_mapper = \Imagely\NGG\DataMappers\Image::get_instance();
    $images = $image_mapper->find_all_for_gallery($id, true);

    I hope that helps.

    Thread Starter ODAK71

    (@odak71)

    Here the whole old code structure. I want to get the last image in gallery and link to the gallery

    $galleryid = $gallery->gid;
    
    $gallery = $nggdb->find_gallery($gallery->gid); 
    $picture_data = $wpdb->get_results("SELECT filename, alttext FROM abcd_ngg_pictures WHERE galleryid=".$galleryid);
    
    $iie = count($picture_data) - 1;
    foreach ( $picture_data as $ng_image ) {
    if ($ii < $iie ) {
    if ($ii == 0) {
    
    $ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;	
    								?>
    								<a class="btn item-btn fancybox" href="<?php echo $ipath; ?>" rel="<?php echo $gallery->gid ?>"><?php echo $moretxt; ?></a>
    							<?php }
    							else {				
    						    $ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;				
    echo  '<a href="'.$ipath.'" class="fancybox" rel="'. $gallery->gid . '" style="display: none;" /></a>';							
    }
    }
    
    $ii = $ii + 1;
    					}

    This dont work:

    $ii = 0;
    
    $gallery_array = array();
    
    $galleryid = $gallery->gid;
    
    $gallery_mapper = \Imagely\NGG\DataMappers\Gallery::get_instance();
    $gallery = $gallery_mapper->find($galleryid);
    
    $image_mapper = \Imagely\NGG\DataMappers\Image::get_instance();
    $picture_data = $image_mapper->find_all_for_gallery($galleryid, true);
    
    $iie = count($picture_data) - 1;
    foreach ( $picture_data as $ng_image ) {
    if ($ii < $iie ) {
    if ($ii == 0) {
    $ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;	
    ?>
    <a class="btn item-btn fancybox" href="<?php echo $ipath; ?>" rel="<?php echo $gallery->gid ?>"><?php echo $moretxt; ?></a>
    <?php }
    else {				
    $ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;				
    echo  '<a href="'.$ipath.'" class="fancybox" rel="'. $gallery->gid . '" style="display: none;" /></a>';
            							// alt="'.$ng_image->alttext.'"
    }
    }
    $ii = $ii + 1;
    }
    • This reply was modified 11 months, 2 weeks ago by ODAK71.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Update 3.5.X crashes – missing nggdb’ is closed to new replies.