Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-----------------------------------------------
- CATEGORY PAGE
- -----------------------------------------------*/
- $categs = new Category($db);
- $list = $categs->list_categs();
- // We find out the id of the category and the requested page (from the pagination)
- $mod_vars = explode("-", $vars);
- $categ_id = $mod_vars[0];
- if(is_numeric($categ_id)){
- $categ_info['categ_id'] = $categ_id;
- if(isset($mod_vars[2])) {
- $filter = $mod_vars[2];
- $categ_info['filter'] = $filter;
- }
- else $categ_info['filter']='n';
- /* ---------------
- LIST OF FILTERS
- n - newest
- r - best rated
- c - most commented
- v - most viewed
- r - random
- */
- $filters = array('n'=>'Newest', 'l'=>'Most Liked', 'c'=>'Most Commented', 'v'=>'Most Viewed');
- //We also find the category name and attach it to the array holding the information
- foreach($list as $i){
- if($i['categ_id']==$categ_id) {
- $categ_info['categ_name'] = $i['categ_name'];
- }
- }
- // We create the images object
- $imgs = new image($db);
- // The page thingie
- if(isset($mod_vars[1])) $categ_info['page_nr'] = $mod_vars[1];
- else $categ_info['page_nr'] = 1;
- // The number of images per page
- $img_per_page = 8;
- // We get the total number of images we could display
- $img_total = $imgs->get_nr_images_from_categ($categ_id);
- $last = ceil($img_total/$img_per_page);
- if($categ_info['page_nr']<1) $categ_info['page_nr']=1;
- elseif($categ_info['page_nr']>$last) $categ_info['page_nr'] = $last;
- $limit1 = ($categ_info['page_nr']-1)*$img_per_page;
- $imgs_list = $imgs->from_categ($categ_info['categ_id'], $categ_info['filter'], $limit1, $img_per_page);
- $smarty->assign('nrpages', $last);
- $smarty->assign('filters', $filters);
- $smarty->assign('categ_info', $categ_info);
- $smarty->assign('imgs', $imgs_list);
- }
- $smarty->assign('categs', $list);
- $smarty->assign('userinfo', $userinfo);
- $smarty->display('application/tpl/categ.tpl');
- ?>
Add Comment
Please, Sign In to add comment