• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query String For CodeIgniter Calendar?

#1
I would like to know if it is possible to be able to have query strings for codeigniter calendar library

So the url would produce some thing like
 
Code:
http://localhost/project/dashboard/calendar?year=2016&month=1


Currently I have to use uri segments for it which works fine but prefer query string url


Code:
http://localhost/project/dashboard/calendar/2016/1


Any Suggestions


PHP Code:
<?php

class Calendar extends MX_Controller {

 
   public function __construct() {
 
       parent::__construct();
 
       $this->load->model('dashboard/model_calendar');
 
       $this->load->library('calendar');
 
       $this->load->library('form_validation');

 
   }

 
   public function index() {    
        if 
($this->uri->segment(3) == FALSE) {
 
           $year date('Y');
 
       } else {
 
           $year $this->uri->segment(3);
 
       }

 
       if ($this->uri->segment(4) == FALSE) {
 
           $month date('m');
 
       } else {
 
           $month $this->uri->segment(4);
 
       }
 
       
        $prefs 
= array(
 
           'start_day' => 'monday',
 
           'show_next_prev' => true,
 
           'month_type'   => 'long',
 
           'day_type' => 'long',
 
           'next_prev_url' => base_url('dashboard/calendar')
 
       );

 
       $prefs['template'] = '
            {table_open}<div class="table-responsive"><table border="0" cellpadding="0" cellspacing="0" class="table table-hover table-striped table-bordered calendar">{/table_open}
            
            {heading_row_start}<tr>{/heading_row_start}
            
            {heading_previous_cell}<th><a href="{previous_url}"><i class="fa fa-chevron-left fa-2x "></i></a></th>{/heading_previous_cell}
            {heading_title_cell}<th class="text-center" colspan="{colspan}">{heading}</th>{/heading_title_cell}
            {heading_next_cell}<th class="text-right "><a href="{next_url}"><i class="fa fa-chevron-right fa-2x"></i></a></th>{/heading_next_cell}
            
            {heading_row_end}</tr>{/heading_row_end}
            
            {week_row_start}<tr >{/week_row_start}
            {week_day_cell}<td class="text-center" style="height: 5rem;">{week_day}</td>{/week_day_cell}
            {week_row_end}</tr>{/week_row_end}
            
            {cal_row_start}<tr class="days">{/cal_row_start}
            {cal_cell_start}<td class="day">{/cal_cell_start}
            
            {cal_cell_content}
                <div class="day_number">{day}</div>
                <div class="content" style="margin-top: 0;">{content}</div>
            {/cal_cell_content}
            {cal_cell_content_today}
                <div class="day_number highlight">{day}</div>
                <div class="content" style="margin-top: 0;">{content}</div>
            {/cal_cell_content_today}
            
            {cal_cell_no_content}
            <div class="day_number">{day}</div>
            {/cal_cell_no_content}
            {cal_cell_no_content_today}
            <div class="day_number highlight">{day}</div>
            {/cal_cell_no_content_today}
            {cal_cell_blank}&nbsp;{/cal_cell_blank}
            
            {cal_cell_end}</td>{/cal_cell_end}
            {cal_row_end}</tr>{/cal_row_end}
            
            {table_close}</table></div>{/table_close}
        '
;

 
       $this->calendar->initialize($prefs);

 
       $this->model_calendar->delete_events();

 
       $this->model_calendar->delete_extra_events();

 
       $events $this->model_calendar->get_calendar_events($year$month);

 
       $data['calendar'] = $this->calendar->generate($year$month$events);

 
       if ($this->uri->segment(3) == TRUE) {
 
           $data['view_more'] = site_url('report/events/' $year .'/'$month);
 
       } else {
 
           $data['view_more'] = site_url('report/events');
 
       }

 
       $this->form_validation->set_rules('event''Calendar Event''trim|required');
 
    
        if 
($this->form_validation->run() == FALSE) {

 
           $this->load->view('dashboard/calender_view'$data);

 
       } else {

 
           if ($this->model_calendar->check_event() == TRUE) {

 
               $this->model_calendar->add_extra_event();

 
           } else {

 
               $this->model_calendar->add_event();

 
           }

 
           $this->session->set_flashdata('added_event''<i class="fa fa-check-circle"></i> You have added event to your calendar!');

 
           redirect('common/dashboard');

 
       }
 
   }



Attached Files
.php   Calendar.php (Size: 4.07 KB / Downloads: 58)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.