PDA

View Full Version : Integration with CakePHP


patricktt
09-16-2009, 01:25 AM
Hi all, not sure how many people are familiar with CakePHP, but I am trying to integrate the calendar into a website which has been built using that. I can access the admin section, I can view the demo calendar, but when i try to invoke the calendar from the website layout, nothing appears..

the code I am using is:

<?php
$CSS = 1; require(WWW_ROOT . 'calendar/calendar.php');
$OL = 1; require(WWW_ROOT . 'calendar/calendar.php');
require(WWW_ROOT . 'calendar/calendar.php');
?>

WWW_ROOT is predefined to be the full path to the /app/webroot/ folder, in which calendar sits. Does the require have to be relative? Because I have tried just 'calendar/calendar.php' and it is still blank...

Any light that can be shed on this would be greatly appreciated.

Thanks

Patrick

ve9gra
09-16-2009, 09:28 AM
Do you have a link to your installation?

For troubleshooting, I will sometimes change the require for an include so that the page can still load...

Are you getting any paths error or anything that would point to what the problem is?

patricktt
09-16-2009, 09:41 PM
Hi there, the calendar should appear on this page:

http://new.stawa.net/

between the end of the navigation and the first advert.

the demo is here: http://new.stawa.net/calendar/demo.php

I get a load of undefined indexes, if I set the variables prior to requiring the files, the warnings disappear, but the calendar doesn't show.

As the demo is working, it has to be something to do with the integration with CakePHP, but I can't see what, is surely it should still set the appropriate variables being required into a php page?

ve9gra
09-16-2009, 11:21 PM
Some CMS do their own filtering when you require some extra code... so it is possible that CakePHP cripples the code and breaks the calendar. But as I have zero experience with CakePHP, take my answer with a grain of salt.

Perhaps their support forums (if they have any) could be of help. They might be able to tell you how to integrate external code into their own.

patricktt
09-16-2009, 11:26 PM
hi there, yes I have tried their forums too, seems I am the first person to try and integrate the two :) CakePHP uses the MVC structure. I might have to try to create a component or something for it, as it would be handy to have the calendar easily integrated with it.. I have spent aver 3 hours so far trying to get it to display but nothing seems to remove the errors! I disabled the calendar so you wont see any errors, but now you are online, if you did want to have a look I can enable it again for you..

Brian
09-17-2009, 10:32 AM
I missed them... What were the errors (specifics)?

patricktt
09-20-2009, 08:40 PM
well they are just warnings, not really errors, and like I say, the demo works, so I know that it is an issue with the integration into CakePHP, though if I can resolve the issues, it would solve a world of problems and mean that I don't have to use a different calendar as this one seems to be perfect for the requirements.

the errors are undefined indexes, starting with getPaths and epcGetInit, but also the theme, css, etc.

from looking at your other integration tutorials, it looks like I will have to build a component or something for CakePHP to bring all the parts together, unless you can think of a reason for the undefined indexes...?

also, i have set the error_reporting level in the code, but I don't have access to the php.ini file and the changes in the code don't seem to be doing much.

ve9gra
09-21-2009, 01:40 PM
The undefined stuff is normal. The proper course of action is to change the error level reporting to exclude warnings.

After removing the warnings from your view, you might see some errors... those are not normal and we will address them if there are any.

AndrewC
09-21-2009, 05:29 PM
Patrick - I am not sure if this will work but have you tried putting the calendar.php file in the app/vendors folder? Then you should be able to just do a require or include of "calendar.php" rather than defining the path.

I am VERY curious to know if you get it working. I am wanting to use this same script myself but am hesitant to purchase until I know it has been successfully integrated into cakephp.

Gervais - If it DOES end up working with cakePHP, I would like to discuss a licensing arrangement with you. I am building a content management system using the cakephp framework and would like to integrate a simple calendar system.

ve9gra
09-21-2009, 08:53 PM
As stated in my signature... I am not affiliated with Easy PHP Calendar. Brian is the guy you're looking for, but he will be unavailable (less available) until next week.

patricktt
09-21-2009, 09:10 PM
hi there, thanks for the input, I will be attempting to get this working again today, and will let you know how I get on! I use CakePHP for 99% of my development projects, so it is also beneficial for me to find an easy solution to integrate this calendar with it.

patricktt
09-21-2009, 11:02 PM
Ok, all sorted. The issue was as you suspected, with the error level. In CakePHP, there is a error level in /app/config/core.php

If this error level is set to 0 (production) the calendar works. If it is set to 1, which is the minimum during development, thats when the warnings appear.

So, this presents a couple of issues... I need that error level set to 1 during development so that I can see what is going on! But with it set to 1, obviously I get a tonne of warnings.

Is there any reason that the coding for the calendar hasn't initiated variables prior to using them, or at least checking if they are set before using them? If not, then I think I will have to go through all the files and put the checks in...

Thanks

Patrick

As a new question, the hover doesn't seem to be working? Also, can I specify a url for the dates to go to when the user clicks on a day?

ve9gra
09-22-2009, 07:23 AM
I can't tell you anything about the code as I've never seen it. It is encrypted to protect Brian's IP (intellectual property.. not IP address :P). Because of that, you will also not be able to add the checks.

For the hover to work, you need the $OL line.

You can specify a URL for when the user clicks on the calendar... something to redirect them to a full calendar page situation. The only way to specify it for each day, then you have to use the 1st part of the Blog mode and tweak the $thisFile variable. In that situation, you'd also have to roll your own navigation (http://www.epctutorials.com/tutorials/create-your-own-navigation-table/).

MatrixDesigns
10-19-2009, 10:30 PM
For anyone who wants to do this
Its rather simple:)


<?PHP
$oldLevel=error_reporting(0);
$CSS = 1; require(WWW_ROOT . 'calendar/calendar.php');
$OL = 1; require(WWW_ROOT . 'calendar/calendar.php');
require(WWW_ROOT . 'calendar/calendar.php');
error_reporting($oldLevel)
?>

patricktt
10-19-2009, 10:48 PM
Where did you put that though? wherever you wanted the calendar? Or did you split it up into the head, body and where the calendar is? does it work in development mode? i.e. debug > 0?

MatrixDesigns
10-19-2009, 10:51 PM
Where did you put that though? wherever you wanted the calendar? Or did you split it up into the head, body and where the calendar is? does it work in development mode? i.e. debug > 0?
Hit me up on AIM or whatever ya want:

natalichwolf - aim
rot_natalicw - yahoo
natalic_wolf@hotmail.com - msn.

I'm a developer.

patricktt
10-20-2009, 05:33 AM
Unfortunately that didn't work ;) Not sure how CakePHP is setting it, but when the site is in debug 0 (production mode), the calendar works, but any other debug setting and there are a tonne of warnings. Also nothing is appearing when you hover over a date but thats a different issue.