I have a CI calendar showing on a page, with an array of data sent to populate each day, and that’s working fine, however I seem to have run into a small problem that I can’t quite wrap my head around.
I’ve only known CI for about 3 days (and OOP based PHP for 5 days!), so forgive me if this is something incredibly simple.
I need to get a variable ($pid) into my calendar’s next/prev links. The $pid will define which property to get from the DB, and to display the properties rates for the selected month.
In my “MY_Calendar.php” file, I have the following:
var $CI;
var $lang;
var $local_time;
var $template = '';
var $start_day = 'sunday';
var $month_type = 'long';
var $day_type = 'abr';
var $show_next_prev = TRUE;
var $next_prev_url = '/ci/index.php/rates/property/1/';
Where the /1/ is in the url, I need that to change to whatever the $pid is of the page that the calendar is on.
How can I get this variable into the class file?
I’m assuming it’d be a simple PHP concatenation to get the variable in the URL.
I tried calling the preferences via “$this->load->library(‘calendar’, $prefs);”
But the preferences didn’t seem to come through (I had a array named $prefs on the same page)
Any ideas? 🙂
If you’ve already extended the CI_Calendar class, just add a new class property:
If you pass in the config array, and you’re calling the parent constructor, it should allow you to pass in / set the
$pidvariable.Then you’d obviously remove that value from
$next_prev_url.Finally, you will override the function that outputs the next/prev buttons to concatenate the
$next_prev_urlwith the correct$pid. You should set$pidto the current page, so teh previous will be -1 and next +1, ofcourse checking for the min and max page number to prevent those links from being shown if you get to the end.