php - Codeigniter Calendar within a div and changing month -
i trying use codeigniter calendar event calendar part of social network similar facebook. in codeigniter manual calendar class, gets call echo $this->calendar->generate()
method within controller. wish appear within div tag on tab on page. ok use echo within view in way?
secondly next_prev_url uses url load next or previous month. use url information user such id. when try use calendar @ moment, takes user_id month or year parameter, giving me view april in year 186 or that. how load next or previous month without using url?
first question: it's ok, it's style. separate logic more view, can assign calendar variable.
$data['calendar'] = $this->calendar->generate(); $this->load->view('myview', $data);
second: don't know why user id inside calendar(maybe unclosed quotes somewhere), there's no need jquery plugin. wrote similar long time ago.
//my-calendar-button inside calendar template jquery(document).on('click', 'a.my-calendar-button', function(e){ e.preventdefault(); var link=this.href; //set link controller in calendar template $.ajax({ url: link, type: "get", datatype: "html", success: function (data) { var result = $('<div />').append(data).find('.my-calendar').html(); $('.my-calendar').hide().html(result).fadein(); }, error: function (xhr, status) { alert("sorry, there problem!"); }, complete: function (xhr, status) { $('.my-calendar').fadein(); } });
and controller code if need:
public function getcalendar($year,$month,$eventtype) { $events=$this->event_model->get_month_events($year,(int)$month,$eventtype); $prefs = array ( 'template' => $this->getcalendartemplate(), 'start_day' => 'monday', 'show_next_prev' => true, 'month_type' => 'long', 'day_type' => 'abr', 'next_prev_url' => '/ajax/calendar/' //it adds year , month automatically ); $this->load->library('calendar', $prefs); $data['calendar']= $this->calendar->generate($year,$month,$events); return $this->load->view('/ajax/calendar',$data); } public function getcalendartemplate() { return $template = ' {table_open}<table>{/table_open} {heading_row_start}<tr>{/heading_row_start} {heading_previous_cell}<th><a class="my-calendar-button" href="{previous_url}"><<</a></th>{/heading_previous_cell} {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell} {heading_next_cell}<th><a class="my-calendar-button" href="{next_url}">>></a></th>{/heading_next_cell} {heading_row_end}</tr>{/heading_row_end} {week_row_start}<tr>{/week_row_start} {week_day_cell}<td>{week_day}</td>{/week_day_cell} {week_row_end}</tr>{/week_row_end} {cal_row_start}<tr>{/cal_row_start} {cal_cell_start}<td>{/cal_cell_start} {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content} {cal_cell_content_today}<a href="{content}">{day}</a>{/cal_cell_content_today} {cal_cell_no_content}{day}{/cal_cell_no_content} {cal_cell_no_content_today}{day}{/cal_cell_no_content_today} {cal_cell_blank} {/cal_cell_blank} {cal_cell_end}</td>{/cal_cell_end} {cal_row_end}</tr>{/cal_row_end} {table_close}</table>{/table_close} '; }
Comments
Post a Comment