Adding multiple variables to calendar days - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Adding multiple variables to calendar days (/showthread.php?tid=68588) Pages:
1
2
|
Adding multiple variables to calendar days - behnampmdg3 - 08-01-2017 Hello; I am using Codeigniter calendar3 and so far I have got it this far -> https://prnt.sc/g2z1co I have a very specific requirement I am not sure how to achieve. I want to check tasks in my database (already do), and when I build the calandar, wanna change the CSS of that day and highlight the div or td or .... Also, I want every single day to be a link (like July 25th on my current code) so I can click and add task etc. I am not that far but I am not sure how to take it from here. In the doc they say it's possible to do whatever. Here is my code: Controller: PHP Code: <?php View PHP Code: <div class="container"> Thanks RE: Adding multiple variables to calendar days - Martin7483 - 08-01-2017 From the documentation PHP Code: $this->load->library('calendar'); Quote:Using the above example, day numbers 3, 7, 13, and 26 will become links pointing to the URLs you’ve provided. You will need to pass a data array that holds an url for each day of a given month This function will generate an array containing the number of days for each month of a passed in year. If you don't pass in a year the current year is used PHP Code: function days_per_month($year = '') RE: Adding multiple variables to calendar days - behnampmdg3 - 08-01-2017 Hey I dont think you read what I wrote. I need to pass multiple values as data. Please read again to see what I mean. I want to style it like http://www.bootstrap-year-calendar.com/#Examples/Full%20example so if there are events in that day the styling changes etc etc. Thank you RE: Adding multiple variables to calendar days - behnampmdg3 - 08-01-2017 anyone? RE: Adding multiple variables to calendar days - behnampmdg3 - 08-02-2017 Is codeigniter forum dead? RE: Adding multiple variables to calendar days - Wouter60 - 08-03-2017 Quote:Is codeigniter forum dead?Certainly not. Maybe there aren't that many users who have customized the calendering class. I agree that the documentation is not very clear about passing data to the class, if you want something else than just one link per day. To make a link of every day in the calendar, in order to edit the information, you could use something like this in the template: PHP Code: {cal_cell_no_content}<a href="controller/method/{year]/{month}/{day}">{day}</a>{/cal_cell_no_content} In the above example, replace controller/method with your own controller/method to edit the information for the given day. The year, month and day are passed as parameters in the URL. E.g. calendar/edit/2017/8/3. The bootstrap calendar shows the appointments when you hover the mouse over the date. You'll need Javascript (or jQuery) to achieve that. In the jQuery function that is triggered when hovering, you can use AJAX to fetch the appointments for that day. RE: Adding multiple variables to calendar days - behnampmdg3 - 08-03-2017 Hey thanks for writing back. I am trying to understand you but there is somethign missing still (it's me not you) I applied your code here -> http://webmoosh.com/ we can track it there. The part I am not getting is passing the values to each day. The jquery and css styling part is easy as long as I can dynamically add classes to each day. First requirement is that every single day is a link. That part is ok for now howver the challenge is dynamcially adding class. Here's what I mean: See here below is the view. I have list of tasks with date in $task array. If the date of the task matches the calendar date then I wanna add a class. PHP Code: while($month<12) Thanks for helping RE: Adding multiple variables to calendar days - Wouter60 - 08-03-2017 Best way (IMHO) is create a MY_Calendar.php in application/libraries. PHP Code: class MY_Calendar extends CI_Calendar { Copy the generate() function from the core class (in system/libraries/Calendar.php) and paste it into MY_Calendar. Now, add an extra parameter to the genarate function, like this: PHP Code: public function generate($year = '', $month = '', $data = array(), $css = array() ) To pass a specific css class for each day, use the same approach as for passing links for each day: PHP Code: $css = array( Inside the new generate() function, write to code for inserting the correct css-class into the output string ($out). RE: Adding multiple variables to calendar days - behnampmdg3 - 08-03-2017 Ok, so far http://webmoosh.com/ The only thing left is "Inside the new generate() function, write to code for inserting the correct css-class into the output string ($out). " Help? RE: Adding multiple variables to calendar days - behnampmdg3 - 08-04-2017 Can you please help me with this part as well? "Inside the new generate() function, write to code for inserting the correct css-class into the output string ($out). " Thanks |