Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7821105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:32:14+00:00 2026-06-02T07:32:14+00:00

I have a calendar controller and model that displays a monthly calendar. A user

  • 0

I have a calendar controller and model that displays a monthly calendar. A user can click on the previous and next hyperlinks to iterate through the months. I have also been able to generate a unique URL for each day, so when someone wants to click on April 10, 2012 for example they will get a URL something like …/2012/04/10. My problem is that when I go to another month, all the date URLs still show April as the month.

Controller

function display($year = null, $month = null) {

    $this->load->model('CalendarModel');

    if ($day = $this->input->post('day')) 
    {
        $this->CalendarModel->add_calendar_data("$year-$month-$day", $this->input->post('data'));
    }

    $data['Calendar'] = $this->CalendarModel->generate($year, $month);

    $this->load->view('Calendar', $data);

}

Model

class CalendarModel extends CI_Model 
{

    var $conf;

    function CalendarModel() 
    {
        $date = (!isset($_GET['month']) && !isset($_GET['year'])) ? time() : strtotime($_GET['month'] . '/1/' . $_GET['year']); 

        $day = date('d', $date); 
        $month = date('m', $date); 
        $year = date('Y', $date);

        $this->conf = array(
            'start_day' => 'sunday',
            'show_next_prev' => true,
            'next_prev_url' => '/CodeIgniter/index.php/Calendar/display'
        );

        $this->conf['template'] = '
            {table_open}<table border="0" cellpadding="0" cellspacing="0" class="calendar">{/table_open}

            {heading_row_start}<tr>{/heading_row_start}

            {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
            {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
            {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

            {heading_row_end}</tr>{/heading_row_end}

            {week_row_start}<tr>{/week_row_start}
            {week_day_cell}<td>{week_day}</td>{/week_day_cell}
            {week_row_end}</tr>{/week_row_end}

            {cal_row_start}<tr class="days">{/cal_row_start}
            {cal_cell_start}<td class="day">{/cal_cell_start}

            {cal_cell_content}
                <div class="day_num">{day}</div>
                <div class="content">{content}</div>
            {/cal_cell_content}
            {cal_cell_content_today}
                <div class="day_num highlight">{day}</div>
                <div class="content">{content}</div>
            {/cal_cell_content_today}

            {cal_cell_no_content}<div class="day_num"><a href="/'.$year.'/'.$month.'/{day}">{day}</a></div>{/cal_cell_no_content}
            {cal_cell_no_content_today}<div class="day_num"><a href="/'.$year.'/'.$month.'/{day}">{day}</a></div>{/cal_cell_no_content_today}

            {cal_cell_blank}&nbsp;{/cal_cell_blank}

            {cal_cell_end}</td>{/cal_cell_end}
            {cal_row_end}</tr>{/cal_row_end}

            {table_close}</table>{/table_close}
        ';

    }

    function generate ($year, $month) 
    {

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

        //$cal_data = $this->get_calendar_data($year, $month);

        return $this->calendar->generate($year, $month);

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:32:15+00:00Added an answer on June 2, 2026 at 7:32 am

    Does this work?

      function CalendarModel($year = null, $month = null, $day = null)
      {       
             //$date = (!isset($_GET['month']) && !isset($_GET['year'])) ? time() : strtotime($_GET['month'] . '/1/' . $_GET['year']);
             //$day = date('d', $date);
             //$month = date('m', $date);
             // $year = date('Y', $date);  
             if ((is_null($year) || (is_null($month))
                 {
                          // Do something if needed?
                 }
    
              $this->conf = array( .... {continue rest of controller here as above}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will have to implement a calendar view/controller that looks pretty much like the
I have calendar in Qt. I want when user selects date, 14(Qint32) will be
I have a basic has_many :through relationship that is bi-directional: calendars have many calendar_calendar_events
I have a php calendar at http://idea-palette.com/aleventcal/calendar.php . I want the days that are
I want to have one model & view that is served by multiple controllers
I have a calendar that I generate. Currently it makes the entire month and
I have a controller action that returns some JSON results to the jQuery Full
I have a calendar, and the user should be able to select dates (they
I have a calendar, and when the user hovers over a cell, a large-ish
I have a calendar that was previously divided into 30min blocks. I am updating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.