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

  • SEARCH
  • Home
  • 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 6175295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:54:02+00:00 2026-05-23T23:54:02+00:00

I have a question about the calendar class. I can populate days in the

  • 0

I have a question about the calendar class. I can populate days in the calendar with data from a database no problem when the url has the year and month in it, but when you first load a page with the calendar, it doesn’t have the year and month in the url so i’m not sure how to figure out the year and month.

How can I populate events in a calendar on page load when there is no year and month in the url?

Controller

    /**
    * memberCalendar - displays the member calendar page
    */
    function memberCalendar()
    {
        $prefs = array (
               'start_day'      => 'sunday',
               'month_type'     => 'long',
               'day_type'       => 'short',
               'show_next_prev' => TRUE,
               'next_prev_url'  => site_url('member/memberCalendar')
             );

        $year = $this->uri->segment(3);
        $month = $this->uri->segment(4);

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

        $events = $this->member_model->get_member_events($year, $month);

        $calendarEvents = array();

        foreach($events as $event) {

            $day = substr($event->event_date, 8, 2);    // get the day

            // if the first digit is a 0, such as in 03, remove the 0 so it becomes 3
            if(substr($day, 0, 1) == 0) {
                $day = substr($day, 1, 1);
            }

            $calendarEvents[$day] = 'http://example.com/news/article/'.$event->event_title;
        }

        $content_data['calendar'] = $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4), $calendarEvents);
        $content_data['firstName'] = $this->session->userdata('firstName');
        $data['sess'] = $this->session;
        $data['content'] = $this->load->view('member/memberCalendar', $content_data, true);
        $this->load->view('template/admin', $data);
    }

Model

/*
    * function which gets the member calendar events
    */
    function get_member_events($year, $month)
    {
        $query = $this->db->select('event_date, event_title, event_content')->from('member_calendar')->like('event_date', "$year-$month", 'after')->get();

        // if there is more than one row
        if($query->num_rows > 0)
        {
            return $query->result();
        } else {
            return false;
        }
    }
  • 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-05-23T23:54:03+00:00Added an answer on May 23, 2026 at 11:54 pm

    I think you’d be better off using parameters and default arguments:

    public function memberCalendar( $year = FALSE, $month = FALSE )
    {
        if( $year === FALSE ) $year = date( 'Y' );
        if( $month === FALSE ) $month = date( 'm' );
    
        // continue as normal until calendar->generate
        $content_data['calendar'] = 
                       $this->calendar->generate($year, $month, $calendarEvents);
    
        // continue as normal
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about XSLT. On a website i have a simple calendar,
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body
I have a question about this formula from a book: EFW (cm,kg)= 10^(-1,7492+(0,166*BPD)+(0,046*AC)-(2,646*AC*BPD/1000)) The
I have question about sending emails from MVC3 application. I already read for exmple
I have question about regexp in TCL. How i can find and change some
Just a quick architecture question really on storing calendar data. Basically, I have a
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all

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.