Advertisement
eventsmanager

events list template limiting categories

Mar 27th, 2012
387
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3.  * Default Events List Template
  4.  * This page displays a list of events, called during the em_content() if this is an events list page.
  5.  * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need.
  6.  * You can display events however you wish, there are a few variables made available to you:
  7.  *
  8.  * $args - the args passed onto EM_Events::output()
  9.  *
  10.  */
  11. if( get_option('dbem_events_page_search') && !defined('DOING_AJAX') ){
  12.     em_locate_template('templates/events-search.php',true);
  13. }
  14.  
  15. //this is the only modification, it limits the default search to category id 3
  16. if( empty($args['category']) && empty($_REQUEST['category']) ){
  17.   $args['category'] = 3;
  18.   $_REQUEST['category'] = 3;
  19. }
  20.  
  21. //TODO fine tune ajax searches - we have some pagination issues otherwise, due to search querystrings
  22. if( get_option('dbem_events_page_ajax', (defined('EM_AJAX_SEARCH'))) ) echo "<div class='em-events-search-ajax'>";
  23. $events_count = EM_Events::count( apply_filters('em_content_events_args', $args) );
  24. $args['limit'] = get_option('dbem_events_default_limit');
  25. $args['page'] = (!empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) )? $_REQUEST['page'] : 1;
  26. if( $events_count > 0 ){
  27.     //If there's a search, let's change the pagination a little here
  28.     if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'search_events'){
  29.         $args['pagination'] = false;
  30.         echo EM_Events::output( $args );
  31.         //do some custom pagination (if needed/requested)
  32.         if( !empty($args['limit']) && $events_count > $args['limit'] ){
  33.             //Show the pagination links (unless there's less than $limit events), note that we set em_search instead of search to prevent conflicts
  34.             $search_args = array_merge(EM_Events::get_post_search(), array('page'=>'%PAGE%','action'=>'search_events','search'=>null, 'em_search'=>$args['search']));
  35.             $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], $search_args, false); //don't html encode, so em_paginate does its thing
  36.             echo apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $events_count, $args['limit'], $args['page']), $page_link_template, $events_count, $args['limit'], $args['page']);
  37.         }
  38.     }else{
  39.         echo EM_Events::output( $args );
  40.     }
  41. }else{
  42.     echo get_option ( 'dbem_no_events_message' );
  43. }
  44. if( get_option('dbem_events_page_ajax', (defined('EM_AJAX_SEARCH'))) ) echo "</div>";
Advertisement
RAW Paste Data Copied
Advertisement