Welcome Guest, Not a member yet? Register   Sign In
Using the calendar class
#1

[eluser]stef569[/eluser]
Hi, I just started using CI after watching the video tut.

I'm trying to create a calendar with links in it and the user should be able to insert a beginning and ending date and all the days between those two dates should be colored red.
I have 2 users, each having it's own name wich should show up as as link Name.

I created a db and connected fine.

I created a controller:

Code:
<?php
class Calender extends Controller {
    
    function Calender() {
        parent::Controller();
        $prefs = array (
    'start_day'    => 'monday',
    'month_type'   => 'long',
    'day_type'     => 'short',
        'show_next_prev' => TRUE,
        'next_prev_url'  => 'http://localhost/CI/index.php/show/'
    );
        $this->load->library('calendar', $prefs);
    }
    
    function index() {
        $data['title']   = 'PHP Calender';
        $data['heading'] = 'heading';
        $this->load->view('calender_view', $data);
    }
}
?>

and a calendar_view:

Code:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
    <h1>&lt;?php echo $heading;?&gt;</h1>
    &lt;?php echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));?&gt;
&lt;/body&gt;
&lt;/html&gt;

The calender shows up.
Now I want the go left and go right arrows to work.
But when I push on then i get a CI 404 page.
I tried manualy to goto the /show/ function but that alsoo produced a 404 error.

What m I doing wrong?
Stef
#2

[eluser]stef569[/eluser]
Note: I'm testing localy and my base url looks like this:
Code:
$config['base_url']    = "http://localhost/CI/";

The following url's return CI 404 page.

http://localhost/CI/index.php/calender/show/2007/12
http://localhost/CI/index.php/show/2007/12
#3

[eluser]gtech[/eluser]
hi, this worked for me, you should be able to cut and paste (all I have really done is renamed the function index to show)

Code:
&lt;?php
class Calender extends Controller {

  function Calender()
  {
    parent::Controller();
    $base = base_url();
    $prefs = array (
      'start_day'    => 'monday',
      'month_type'   => 'long',
      'day_type'     => 'short',
      'show_next_prev' => TRUE,
      'next_prev_url'  => $base."index.php/calender/show"
     );
     $this->load->library('calendar', $prefs);
  }
    
  function show() {
        echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
  }
}
?&gt;
#4

[eluser]stef569[/eluser]
Thanks for the reply gtech,
I understand now :p I tought show was a calender function but it's realy a function you make up yourself...




Theme © iAndrew 2016 - Forum software by © MyBB