Welcome Guest, Not a member yet? Register   Sign In
Calender Class
#1

[eluser]foysal[/eluser]
Hi all

I would like to make a link with the individual date. that means if I click on a date it will take me to another page.

I tried a lot with calender template.But could not solve the problem.

How can I do that?? Have you any idea about it??


Foysal
#2

[eluser]osci[/eluser]
did u read the user guide?

Section "Passing Data to your Calendar Cells" exactly describes how to do it.
#3

[eluser]foysal[/eluser]
Dear osci

I read the user guide. but “Passing Data to your Calendar Cells” section could not make the link . It prints the specific date's value of the array at the specific date's cell . If it can make link that will be great help for me.

thanks for reply


Foysal
#4

[eluser]osci[/eluser]
As of user guide:
Quote:To add data to your calendar cells involves creating an associative array in which the keys correspond to the days you wish to populate and the array value contains the data. The array is passed to the third parameter of the calendar generating function. Consider this example:
Code:
$this->load->library('calendar');
$data = array(
               3  => 'http://example.com/news/article/2006/03/',
               7  => 'http://example.com/news/article/2006/07/',
               13 => 'http://example.com/news/article/2006/13/',
               26 => 'http://example.com/news/article/2006/26/'
             );

echo $this->calendar->generate(2006, 6, $data);
Using the above example, day numbers 3, 7, 13, and 26 will become links pointing to the URLs you've provided.
Quote:Note: By default it is assumed that your array will contain links. In the section that explains the calendar template below you'll see how you can customize how data passed to your cells is handled so you can pass different types of information.
If you just do that doesn't it provide you with links?
Are you using a calendar template?
#5

[eluser]foysal[/eluser]
Dear osci


At first my code was like below..



function show_calender()
{
if ($this->session->userdata('logged_in') == TRUE)
{
$vars['calendar'] = $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));


$page_to_send_view =array();
$page_to_send_view['calendar']=$this->load->view('calendar',$vars,true);
$this->load->view('loggedin',$page_to_send_view);

}
else
{
redirect('login/log');
}
}




After getting your advice I used the following code




function show_calender()
{
if ($this->session->userdata('logged_in') == TRUE)
{

$this->load->library('calendar');

$data = array(
3 => 'http://example.com/news/article/2006/03/',
7 => 'http://example.com/news/article/2006/07/',
13 => 'http://example.com/news/article/2006/13/',
26 => 'http://example.com/news/article/2006/26/'
);





$vars['calendar'] = $this->calendar->generate(2006, 6, $data);




$page_to_send_view =array();
$page_to_send_view['calendar']=$this->load->view('calendar',$vars,true);
$this->load->view('loggedin',$page_to_send_view);

}
else
{
redirect('login/log');
}
}



If I use above code the output looks like below.


______________________
|3 |
| |
| http://example.com/ |
| news/article/2006/03/ |
| |
|_____________________|



help me please. I am in problem.



thanks for reply



Foysal
#6

[eluser]osci[/eluser]
Well I used your code (btw use the code tag when posting code, it's easier to read and copy) and wrote two simple views just echoing the data passed and everything works fine.
#7

[eluser]foysal[/eluser]
Dear osci

Can you send me your screen shot please? my email address is [email protected] . Or can you send your email address, so that I can send you my screen shot.



thanks for reply


Foysal
#8

[eluser]osci[/eluser]
This is the output in source code.

Code:
<table border="0" cellpadding="4" cellspacing="0">

<tr>
<th colspan="7">June&nbsp;2006</th>

</tr>

<tr>
<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>

</tr>

<tr>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>1</td><td>2</td><td><a href="http://example.com/news/article/2006/03/">3</a></td>
</tr>

<tr>
<td>4</td><td>5</td><td>6</td><td><a href="http://example.com/news/article/2006/07/">7</a></td><td>8</td><td>9</td><td>10</td>

</tr>

<tr>
<td>11</td><td>12</td><td><a href="http://example.com/news/article/2006/13/">13</a></td><td>14</td><td>15</td><td>16</td><td>17</td>
</tr>

<tr>
<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>

</tr>

<tr>
<td>25</td><td><a href="http://example.com/news/article/2006/26/">26</a></td><td>27</td><td>28</td><td>29</td><td>30</td><td>&nbsp;</td>
</tr>

</table>
#9

[eluser]foysal[/eluser]
Dear osci

I am not clear. How did you find this code?? Where do you want to place this code?? I mean do you want to put this code in model ?? or view?? or controller ??

It is better for me if you send model, view and controller code.

I am useing code like below in my contorller.

Code:
function show_calender()
            {
              if ($this->session->userdata('logged_in') == TRUE)
                {    

                   $this->load->library('calendar');

$data = array(
               3  => 'http://example.com/news/article/2006/03/',
               7  => 'http://example.com/news/article/2006/07/',
               13 => 'http://example.com/news/article/2006/13/',
               26 => 'http://example.com/news/article/2006/26/'
             );



                   $vars['calendar'] = $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4),$data);


                    $page_to_send_view =array();
                    $page_to_send_view['calendar']=$this->load->view('calendar',$vars,true);
                    $this->load->view('loggedin',$page_to_send_view);
                    
         }
         else
         {
           redirect('login/log');
         }


I am attaching a screen shot of my output for you.


thanks for reply


Foysal
#10

[eluser]osci[/eluser]
That was the found by looking at source code of page in browser, after it's executed.

Anyway I'll post you the controllers - views, model would be used when you get the array $data described later from another source (db, file...)

Controller
Code:
&lt;?php defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller {

   function __construct()
   {
      parent::__construct();
   }

   function index()
   {
      $this->load->library('calendar');

      $data = array(
         3 => 'http://example.com/news/article/2006/03/',
         7 => 'http://example.com/news/article/2006/07/',
         13 => 'http://example.com/news/article/2006/13/',
         26 => 'http://example.com/news/article/2006/26/'
      );

      $vars['calendar'] = $this->calendar->generate(2006, 6, $data);
      $page_to_send_view =array();
      $page_to_send_view['calendar_display']=$this->load->view('calendar',$vars,true);
      $this->load->view('test',$page_to_send_view);
   }
}

View calendar (subview)
Code:
&lt;?php echo $calendar;

View test (main view)
Code:
&lt;?php echo $calendar_display;

and it produces a basic calendar with links as of screenshot

In your calendar generator you are using segments. Are they set? Try with http://localhost/CodeIgniter/index.php/l...dar/2006/6




Theme © iAndrew 2016 - Forum software by © MyBB