Welcome Guest, Not a member yet? Register   Sign In
Some question about "Showing Next/Previous Month Links"
#1

[eluser]Unknown[/eluser]
Dear,
I am a beginner to CI. I want to tell u the framework is awesome. I love it very much.
I want to use it to build my website, so I reading the user guide carefully, but I found some question about "Showing Next/Previous Month Links" in "Calendar Class" section.
The following code was copied from "Calendar Class" section:
Code:
$this->load->library('calendar');
$prefs = array (
               'show_next_prev'  => TRUE,
               'next_prev_url'   => 'http://www.your-site.com/index.php/calendar/show/'
             );

echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4), $prefs);
I wrote this code in my conllter, but it showing calendar only, without prev and next link. So I rewrite the code like this:
Code:
$prefs = array (
  'show_next_prev'  => TRUE,
  'next_prev_url'   => 'http://localhost:8080/CodeIgniter_1.5.4/index.php/blog/ShowCalendar/'
);

$this->load->library("calendar", $prefs);
echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
It is work, and showing calendar with prev and next link. The difference just is the parameter "$prefs" was placed different position. Is this really?
#2

[eluser]gtech[/eluser]
Hi I tried it out as well and had the same problem. If you read the generate function in the calender code (system\libraries\calendar.php) you will find that show_next_prev and next_prev_url is retrieved from the config, not the data you pass in to the generate function.

the below code will also work:
Code:
$this->load->library("calendar");
$this->calendar->show_next_prev = TRUE;
$this->calendar->next_prev_url = 'http://localhost:8080/CodeIgniter_1.5.4/index.php/blog/ShowCalendar/';

echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));

The 'fix' you have in the original post is how the code expects you to set everything up and the documentation example appears to be wrong!.. maybe log a bug about the documentation? (might be worth searching the forums to see if its been logged before).

the 3rd parameter on the generate function is used to enable you to set up links on various days, and that does work as the documentation describes.
#3

[eluser]Sumon[/eluser]
I am facing problem in same way. Lets have with example

http://localhost/OneHotNanny/index.php/e...stEventCal

Code:
funciton TestEventCal()
{
$year=$this->uri->segment(3);
$month=$this->uri->segment(4);
if($year=="") $year=date("y");
if($month=="") $month=date("m");

echo "Test Event Calendar with Year:$year and Month: $month<br />";
$base_url=base_url();
$data = array(
               3  => $base_url.'EventCalendar/TestEventCal/'.$year.'/'.$month.'/03/',
               7  => $base_url.'EventCalendar/TestEventCal/'.$year.'/'.$month.'/07/',
               13 => $base_url.'EventCalendar/TestEventCal/'.$year.'/'.$month.'/13/',
               26 => $base_url.'EventCalendar/TestEventCal/'.$year.'/'.$month.'/26/'
             );
echo $this->calendar->generate($year, $month, $data);
}
I expect my Next Month link as
http://localhost/OneHotNanny/index.php/e...ar/2008/05
But In Fact it linked
http://localhost/OneHotNanny/index.php/e...al/2008/05
Would you guys please help me to resolve it ASAP.
#4

[eluser]obobo[/eluser]
I am using the following and the next / previous links are being created properly:
Code:
$prefs['show_next_prev']=TRUE;
$prefs['next_prev_url']=site_url('calendar/month/');
$calendar = $this->calendar->generate($year, $month,$data);




Theme © iAndrew 2016 - Forum software by © MyBB