Really simple question: How to use calendar on home controller?

#1
[eluser]victorche[/eluser]
Let me explain ... I want to have a calendar on the index page, in my case, this is the welcome controller. And I want this calendar to have prev/next month links. When I click on the next month for example, I want the url to be:
http://example.com/2011/03
And I want there the same index (welcome controller), only with the new month displayed.
And I am doing it like this:
Code:
function index($year = NULL, $month = NULL)
{
    $prefs = array(
    'start_day' => 'monday',
    'show_next_prev' => TRUE,
    'next_prev_url' => base_url()
    );
    $this->load->library('calendar', $prefs);
    $calendar = $this->calendar->generate($year, $month);

    $data = array(
        'calendar' => $calendar
    );
}
Simple, isn't it?
Anyway, I am using CI without index.php in the urls. I mean, it is removed in the config and it is removed also with .htaccess.
But this simple thing is not working... When I click on the prev/next month, it gives me 404 error.
I tried with the routes option, but again no success.
Any ideas?

#2
[eluser]Cristian Gilè[/eluser]
Code:
http://example.com/2011/03
is not a valid URL. 2011 and 03 are two parameters. Controller name and method name are missing.

This is a valid URL:
Code:
http://example.com/welcome/index/2011/03


Cristian Gilè

#3
[eluser]victorche[/eluser]
Yes, I know this ... but the strange thing is ... even if I add /welcome/index/ in the url, it still says "Error 404". And I thought, I can fix this somehow with the routes, but no success Sad

#4
[eluser]victorche[/eluser]
my mistake! it works! So the question is ... how can i fix this with the routes ... ?

#5
[eluser]Cristian Gilè[/eluser]
Code:
$route['(:num)/(:num)'] = 'welcome/index/$1/$2';


Cristian Gilè


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.