Closed lstables closed 10 years ago
Hi Lee, what do you mean by it doesn't work?
To make the calendar take into account the cdate variable, you need to look for it and set it before you generate the new calendar. Here is an example:
$date = Input::get('cdate'); // You should sanitize the data here. $cal = Calendar::make(); $cal->setDate($date); $data['calendar'] = $cal->generate();
and then you pass the data array to your view.
Sorry doesn't work was the wrong thing to say I mean what does or where does the date var come from
You need to pick it up from the $GET array, in Laravel, you do that with Input::get('name_of_variable'). Or in this case: $date = Input::get('cdate');
Oh right I see sorry I misunderstood the docs
No worries. I'm glad I could help.
Sorry again but what should this be set as or is this part of the package again looks like am misunderstanding something here ;)
What do you mean by "this"? Did you skip posting something?
No no worries I'll figure it out
Sorry again, but where is the Input::get('cdate') set where does this come from?
When you're preparing the data for the view, you need to get and set the cdate. For testing purposes I put that in my controller. Input::get is the Laravel way of getting data from a form or other input like a url (http://laravel.com/docs/requests#basic-input).
When you click left or write to move to a different month/date, you're using the same controller and the same view, but this time the url has some parameters that you need to use. So you need to get the date, regenerate the calendar view and submit it to the view.
Yes I understand the Input method but get what the date('Y') ?
This is your URL: admin/employees/edit/?cdate=2014-07
You want to get the variable called cdate with a value of 2014-07. So you do that with Input::get('cdate'); If the parameter was called mydate, as in ?mydate=2014-07, you would do Input::get('mydate'). Does this make more sense?
Which is what it is getting admin/employees/edit/?cdate=2014-07 but i just get a blank page when moving through the months
Full code
$cal = Calendar::make();
$cal->setDate(Input::get('cdate')); //Set starting date
$cal->setBasePath('/admin/employees/edit/'); // Base path for navigation URLs
$cal->showNav(true); // Show or hide navigation
$cal->setView(Input::get('cv')); //'day' or 'week' or null
$cal->setStartEndHours(8,20); // Set the hour range for day and week view
$cal->setTimeClass('ctime'); //Class Name for times column on day and week views
$cal->setEventsWrap(array('<p style="font-weight: bold; color: #258DBA; width: 20%;">', '</p>')); // Set the event's content wrapper
$cal->setDayWrap(array('<div style="padding: 0px; margin: 0px;">','</div>')); //Set the day's number wrapper
$cal->setNextIcon('<i class="fa fa-chevron-right"></i>'); //Can also be html: <i class='fa fa-chevron-right'></i>
$cal->setPrevIcon('<i class="fa fa-chevron-left"></i>'); // Same as above
$cal->setDayLabels(array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')); //Label names for week days
$cal->setMonthLabels(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')); //Month names
$cal->setEvents($new_events); // Receives the events array
$calendar = $cal->generate();
If you're getting a blank page, you might not be passing the data to the view correctly. Can you post some of your code in laravel.io/bin?
How are you passing $calendar to the view?
http://laravel.io/bin/W1aMz calendar is passed to the view
then the view is - http://laravel.io/bin/MbBvr
The code looks fine. When you move through the months do you see the Employees Create Event form at all?
What is the initial URL for accessing that page?
When I first go to the calendar tab I get this http://cl.ly/image/0O1i0N080T3I
Then when I click next month (july) I get this http://cl.ly/image/0w42271M3z2J
In the first view you have /edit/1. Is that "1" an employee ID? That's missing in the 2nd url.
Try going to: carehome.app:8000/admin/employees/edit/1?cdate=2014-08. If this works, then you'll need to update the base path to $cal->setBasePath('/admin/employees/edit/' + $employeeID); Where employeeID is something that you can get in your controller.
Yes that worked, so I was missing the URI edit number then, I'll amend my controller to do this, thanks man.
Nice! You're welcome.
Yep $cal->setBasePath('/admin/employees/edit/' + $id); worked a treat, thanks again dude!
I have a problem, the calendar works but when navigating (in Laravel of course) for next and previous months I get this URI admin/employees/edit/?cdate=2014-07 but the last segment doesn't seem to work.
Any idea's?
Cheers, Lee