![]() |
|
Need help with mod_rewrite - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Need help with mod_rewrite (/thread-1304.html) |
Need help with mod_rewrite - SubJunk - 2007-03-19 Hi guys, I'm trying to get next and previous links for my album pages. The album pages are using my modified show_highest_rating function (which I posted here a while back) Anyway here is the code I'm trying to get to work: `if(isset($_SESSION['album_start'])) { $offset=intval($_SESSION['album_start']); print "n<!-- Start parameter set to $offset -->n"; } else { $offset=0; print "n<!-- No start parameter: set to 0 -->n"; } $perpage=25; // images per page show_highest_rated($offset,$perpage); // Show images thumbnails from $st for $pp function show_highest_rated($offset,$perpage) { $images=load_highest_rated(); $size = '_'.zp_conf('thumb_size').'_cw'.zp_conf('thumb_crop_width').'_ch'.zp_conf('thumb_crop_height'); $max=count($images);` `for($i=$offset;$i<$offset+$perpage && $i<count($images);$i++) { print "<!-- $i on $max -->n"; $image=$images[$i]; $filename = $image['filename']; $album = $image['folder']; $desc = $image['imgtitle']; $totalvalue = @number_format($image['totalvalue']/$image['votes'],2); echo '<div class="latestimage2">'; echo '[img]'.WEBPATH.'/zen/i.php?a='.$album.'&i='.$filename.'&s=thumb[/img]</div>'; } // Here: print navigators $offset=$_SERVER['PHP_SELF']; $album=strtolower(getAlbumTitle()); if($offset>0) { $prev=max($offset-$perpage,0); print "<< prev "; } if($offset+$perpage<count($images)) { $next=min($offset+$perpage,count($images)-1); print "next >> "; } } // Load image list for current selected album function load_highest_rated() { $album=getAlbumTitle(); $pagname="pag_".$album; $aryImages=array(); // This album is in the session if(isset($_SESSION[$pagname])) { //print "n<!-- load from session -->n"; $aryImages=$_SESSION[$pagname]; } else { // Album not in session: load it from db $aryImages = query_full_array("SELECT images.albumid, images.filename AS filename, images.title AS imgtitle, ratings.total_value AS totalvalue, ratings.total_votes as votes, albums.folder AS folder, albums.title FROM images AS images JOIN albums AS albums JOIN ratings ON albums.id = images.albumid ON images.id = ratings.id WHERE albums.title = '".getAlbumTitle()."' ORDER BY (ratings.total_value/ratings.total_votes) DESC"); $_SESSION[$pagname]=$aryImages; //print "n<!-- load from db -->n"; } return $aryImages;` And I've added this to index.php in the main folder: `session_start(); if(isset($_GET['offset'])) { $_SESSION['album_start']=$_GET['offset']; die("debug: start param found"); } else { unset($_SESSION['album_start']); }` As far as I can tell the reason it isn't working is because of mod_rewrite (though I'm probably wrong so hopefully you can tell me what's wrong) I've tried adding this to .htaccess: `RewriteRule ^([^/]+)/offset/([0-9]+)/$ index.php?album=$1&offset=$2 [L,QSA]` But it doesn't work. You can see it in action here http://www.dualmonitorbackgrounds.com/abstract/ When you click "next >>" it just goes back to the page instead of the offset page. Please help |