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

[eluser]E303[/eluser]
How would I go about selecting the posts from a database then linking them up.

So far I have a model which selects all of the post dates.

In the controller I have called the calendar, but I am not sure how to conver the results into the
$data = array(
$day => 'url/$id',
$day => 'url/$id'
);

required... Do I do tht in a foreach loop with in the controller like:

$this->Blog_Model->Archive();
$data = array( ".
foreach ($archive as $item)
{
$item['day'] => 'url/$item['id'];
}
".);
#2

[eluser]lefrog[/eluser]
I have set up my prefs and loaded the calendar library in my controller and I have done the following in my view

Code:
<?php
                $this->db->orderby('event_date', 'asc');
                $query = $this->db->get('events', 1);
                $result = $query->row_array();
                echo "<h4>".$result['event_title']."</h4>";
                $limited_txt = word_limiter($result['event_details'], 15);
                echo "<p>$limited_txt</p>";
                
                
                $data = array();
                //$current_month = date('m');
                if ($this->uri->segment(2) == "calendar") {
                    $current_month = $this->uri->segment(5);
                }
                else
                {
                    $current_month = date('m');
                }
                $this->db->where('MONTH(event_date)', $current_month);
                $this->db->select('event_id, event_title, event_date');
                $this->db->orderby('event_date', 'desc');
                $query = $this->db->get('events');
                if($query->num_rows() > 0)
                {
                    foreach($query->result() as $row):
                        $day = date('d', strtotime($row->event_date));
                        $data[$day] = site_url("event_item/$row->event_id");
                    endforeach;
                }
                
                
                echo $this->calendar->generate($this->uri->segment(4), $this->uri->segment(5), $data);
                
                ?&gt;

And this adds the links to the calender.
#3

[eluser]ericsodt[/eluser]
I am having an issue with the Calendar class... I am new to code igniter so please bare with me.

Given the example for creating <<previous and next >> links
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 am unable to see the links as it stands now. I am guessing that there is other code needed, however there is no documentation for me to look at to see what I am missing.

My main goal is to create a calendar and when the day is clicked retrieve some information about that day and display it on another page.

I am looking to give the user the opportunity to go to the previous and next month aswell and that is where I am having a problem.

Any help with this is greatly appreciated.

Thanks
#4

[eluser]lefrog[/eluser]
Try to load your prefs into your library and any data you wan't to pass to dates in the calendar you pass to generate

Try it like this:

Code:
$prefs = array (
               'show_next_prev'  => TRUE,
               'next_prev_url'   => 'http://www.your-site.com/index.php/calendar/show/'
             );

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

$data = array(
               10  => 'http://mysite.com/test/1/',
               12  => 'http://mysite.com/test/2/',
             );

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




Theme © iAndrew 2016 - Forum software by © MyBB