LaravelCalendar icon indicating copy to clipboard operation
LaravelCalendar copied to clipboard

Problem and solution for using segments = true

Open meltz opened this issue 10 years ago • 2 comments

This is a good calendar package, just want to share the problem encountered and how to solve it. If you set segment to true and have problem navigating to the next or prev month due to duplicated year and month parameters url.

In vendor\gloudemans\calendar\src\Gloudemans\Calendar, change line 26 from $this->next_prev_url = $request->url(); to $this->next_prev_url = $request->root().'/'.$request->segment(1);

meltz avatar Jul 31 '14 17:07 meltz

@meltz: Your solution only works when the calendar is on a page that has a URL that consists of only a single segment. It'd be handy if there were a config option for setting the base url of the page that the year and month parameters get appended to. I'll try to find time to put together a pull request soon.

craigsssmith avatar Jun 11 '15 11:06 craigsssmith

try this code... i use this code in CI and Laravel

public function calendar($y = null, $m = null){
      $config = array('show_next_prev'  => true,
                         'next_prev_url'  => url('calendar'),
                         'segments' => true);
      Calendar::initialize($config);
      echo Calendar::generate($y, $m);
}

zawaruddin avatar Mar 15 '16 12:03 zawaruddin