Guest User

Untitled

a guest
Jan 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------
  3. CATEGORY PAGE
  4. -----------------------------------------------*/
  5. $categs = new Category($db);
  6. $list = $categs->list_categs();
  7.  
  8. // We find out the id of the category and the requested page (from the pagination)
  9. $mod_vars = explode("-", $vars);
  10. $categ_id = $mod_vars[0];
  11. if(is_numeric($categ_id)){
  12.         $categ_info['categ_id'] = $categ_id;
  13.         if(isset($mod_vars[2])) {
  14.             $filter = $mod_vars[2];
  15.             $categ_info['filter'] = $filter;
  16.         }
  17.             else $categ_info['filter']='n';
  18.        
  19.         /* ---------------
  20.         LIST OF FILTERS
  21.         n - newest
  22.         r - best rated
  23.         c - most commented
  24.         v - most viewed
  25.         r - random
  26.         */
  27.        
  28.         $filters = array('n'=>'Newest', 'l'=>'Most Liked', 'c'=>'Most Commented', 'v'=>'Most Viewed');
  29.        
  30.         //We also find the category name and attach it to the array holding the information
  31.         foreach($list as $i){
  32.             if($i['categ_id']==$categ_id) {
  33.                 $categ_info['categ_name'] = $i['categ_name'];  
  34.             }
  35.         }
  36.        
  37.         // We create the images object
  38.         $imgs = new image($db);
  39.         // The page thingie
  40.         if(isset($mod_vars[1])) $categ_info['page_nr'] = $mod_vars[1];
  41.             else $categ_info['page_nr'] = 1;
  42.             // The number of images per page
  43.             $img_per_page = 8;
  44.             // We get the total number of images we could display
  45.             $img_total = $imgs->get_nr_images_from_categ($categ_id);
  46.             $last = ceil($img_total/$img_per_page);
  47.                 if($categ_info['page_nr']<1) $categ_info['page_nr']=1;
  48.                     elseif($categ_info['page_nr']>$last) $categ_info['page_nr'] = $last;
  49.             $limit1 = ($categ_info['page_nr']-1)*$img_per_page;
  50.         $imgs_list = $imgs->from_categ($categ_info['categ_id'], $categ_info['filter'], $limit1, $img_per_page);
  51.         $smarty->assign('nrpages', $last);
  52.         $smarty->assign('filters', $filters);
  53.         $smarty->assign('categ_info', $categ_info);
  54.         $smarty->assign('imgs', $imgs_list);
  55. }
  56.  
  57. $smarty->assign('categs', $list);
  58. $smarty->assign('userinfo', $userinfo);
  59. $smarty->display('application/tpl/categ.tpl');
  60. ?>
Add Comment
Please, Sign In to add comment