Hello,
I’ve made quite a bit of progress on this, added an “all” button to the widget next to “recent” and “random” through widgets.php within the nextgen-gallery widgets folder. The following is the code for adding the button.
<label for="<?php echo $this->get_field_id('type'); ?>_all">
<input id="<?php echo $this->get_field_id('type'); ?>_all" name="<?php echo $this->get_field_name('type'); ?>" type="radio" value="all" <?php checked("all", $instance['type']); ?> /> <?php _e('all','nggallery'); ?> </label>
Next I copied the section of code (further down in widgets.php) which obtains the Image list through a Select statement modifying it to obtain all (without a limit). I placed a filter before the loop to display images to determine if ‘all’ type was selected.Used the values which the user selects to determine how many images per page (mine is 6 in my previous post) and used these values in array_slice to get a page by page snippet of images. My pagination links identify the correct navigation which is confirmed when I click on them which then puts that value in the address bar… eg http://www.example.com/testing?pagenum=2.
With this nothing updates, I think the function I placed it in only gets called once despite being refreshed (its an included file). I manually changed the pagenum variable and reloaded the page which worked perfectly, just needed it to update by clicking on the >> pagination hyperlink. Below is the Code for the SQL query(immediately after the other statements) and filtering (before the foreach(Imagelist as Image).
if ( $instance['type'] == 'random' )
$imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list ORDER by rand() limit {$items}");
elseif ( $instance['type'] == 'recent added')
$imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list ORDER by pid DESC limit 0,$items");
else
// Custom code, for other type of 'all'
$imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt on t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list");
<----- code in between not copied to this post ---->
if (is_array($imageList)){
//Custom code for displaying images with pagination
if ($instance['type']=='all') {
if(!(isset($pagenum))) {
$pagenum=1;
}
if($pagenum!=1){
$startimage = $pagenum - 2 + $instance['items'];
} else {
$startimage = $pagenum - 1;
}
$imageCount = count($imageList);
$totalpages = ceil($imageCount/$instance['items']);
$DisplayArray = array_slice($imageList,$startimage,$instance['items']);
foreach($DisplayArray as $image) {
// Same code as the foreach (imagelist as image)
echo $out . ''."\n";
}
// Code for pagination << and >>
$next=$pagenum+1;
$previous=$pagenum-1;
if ($pagenum==1) {
echo "<a href='$pagenow?pagenum=$next'> >> </a>";
}
elseif($pagenum==$totalpages) {
echo "<a href='$pagenow?pagenum=$previous'> << </a>";
}
else {
echo "<a href='$pagenow?pagenum=$next'> >> </a>";
echo " " ;
echo "<a href='$pagenow?pagenum=$previous'> << </a>";
}
}
//Start of Original Code without Pagination
else
foreach($imageList as $image) {
Thats it, I think I need to convert it to an independent function and call it from maybe page.php and update the page number as a parameter.
I apologise if I haven’t explained it well there was a bit to get through. Any further details just ask and I’ll confirm or explain a little better.