Removing duplicate content issue with index.php
Hi all. I have recently put live a new website using cakePHP. I am trying to work out if there is any way of removing a potential duplicate content issue. The problem is that www.example.com/ and www.example.com/index.php both resolve to the same content. Is there any way of redirecting index.php back to / in order to remove this issue? Alternatively is there any way of forcing routes to recognise / index.php so I can set a different action? Many thanks Duncan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
calling $this->validate in a controller fails
Hi all. Cake is producing a fatal error when I call the validate function. I believe I am doing it correctly, but wanted to double check as I am still fairly new to Cake. My (overly simplified) model looks like this class Content extends AppModel { var $name = 'Content'; var $useTable = false; var $validate = array( "sitename"=>VALID_NOT_EMPTY ); } The relevant function in my controller looks like this function diff(){ //Validate Errors fails // $this->validateErrors($this->data); //As does Validate $this->validate($this->data); //a call to save works fine (and gives the validation errors) $this->Content->save($this->data) } The error i am getting is Fatal error: Call to a member function on a non-object in /removed/ cake/libs/controller/controller.php on line 514 Line 514 (I know not much use on its own) looks like $errors = array_merge($errors, $this->{$object->name}- >invalidFields($object->data)); The problem is that $object->name is empty. Am I using the function incorrectly or is there something else causing the problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Between Join producing invalid SQL
Rahul offered the following solutions, but these didn't work either - does anyone have any other suggestions? $conditions['AND']['Target.month'] = "BETWEEN \'$startMonth\' and \'$endMonth\'"; This lead to the following sql, which didn't work SELECT `Target`.`id`, `Target`.`month`, `Target`.`income_type`, `Target`.`target`, `Target`.`actual` FROM `targets` AS `Target` WHERE `Target`.`month` BETWEEN '200707 and 200710' AND (`Target`.`month` BETWEEN '\\\'200707\\\' and \\\'200710\\\'') ORDER BY `Target`.`income_type` ASC, `Target`.`month` asc or $conditions['AND']['Target.month'] = "BETWEEN ".$startMonth. " and ".$endMonth"; This one generates the same as my original query SELECT `Target`.`id`, `Target`.`month`, `Target`.`income_type`, `Target`.`target`, `Target`.`actual` FROM `targets` AS `Target` WHERE `Target`.`month` BETWEEN '200707 and 200710' AND (`Target`.`month` BETWEEN ' 200707 and 200710') ORDER BY `Target`.`income_type` ASC, `Target`.`month` asc I've been banging my head against this for ages but have had no luck. Between is such a generic term that none of the searches I have tried have come up with anything good either. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Between Join producing invalid SQL
Hi All. I'm fairly new to coding in Cake and can't find any resource to help me solve this problem. I appear to be doing the same as all the code snippets I have seen, but I must be missing something. The following code $conditions['AND']['Target.month'] = "BETWEEN $startMonth and $endMonth"; $targets = $this->Target->findAll($conditions); produces this SQL SELECT `Target`.`id`, `Target`.`month`, `Target`.`income-type`, `Target`.`target`, `Target`.`actual` FROM `targets` AS `Target` WHERE `Target`.`month` BETWEEN '200707 and 200710' but this isn't valid. What I was hoping for was SELECT `Target`.`id`, `Target`.`month`, `Target`.`income-type`, `Target`.`target`, `Target`.`actual` FROM `targets` AS `Target` WHERE `Target`.`month` BETWEEN '200707' and '200710' Note the extra 2 quotes after the first date and before the second date. After giving up on this I tried to solve it by changing the code to target.month >= '200707' and target.month <= '200710' but I couldn't work out how to do this either. I could obviously do either by using a custom sql statement, but that feels like cheating and isn't going to help me learn whats going on! Your help is greatly appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please help with the structure of my code
Thanks Grant. That looks like a good way of doing things. I'll have a play doing it that way, and see what I come up with. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Please help with the structure of my code
Hi all. I am an experienced php developer but a very inexperienced Cake developer. I have previously written my own MVC code (though i suspect I blurred the M,V and the C a bit much ;-) ) I am struggling with working out the best way of doing things, and I can't find any decent structure of code discussions. Rather than waffling, I'll give a specific example. I have a Locations model which has an id, and city and a postcode. I created a locations/find, which was passed the data from a form. I then started to extend the find function so that it could also take in data from the url eg /locations/find/leeds Is this the optimal way of doing it, since my find function now has to deal with the data in a different way. The other option would be to create /locations/city/leeds, but I believe this would require another view, and that seems like duplication of effort. If anyone could point me at a worked example with discussion ala the blog tutorial from the manual, but that goes into *alot* more breadth - I'm happy reading functions specs, i just wan't to make sure I am doing things in as close to an optimal way as I can, or else I believe I will lose the rapid part of the Rapid application development! Many thanks for your help.. Regards Duncan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Undefined Constant VALID_EMAIL assumed 'VALID_EMAIL'
Hi Larry. Thanks for your reply.. I originally had the code you mentioned, which caused the error. I then tried a few options. I thought I had set it back to how you had. Changing it to the following code still gives the error. var $validate = array('email' => VALID_EMAIL); Notice: Use of undefined constant VALID_EMAIL - assumed 'VALID_EMAIL' in /var/www/html/live/cake/dispatcher.php on line 157 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/live/cake/dispatcher.php: 157) in /var/www/html/live/cake/libs/session.php on line 154 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/live/cake/dispatcher.php:157) in /var/ www/html/live/cake/libs/session.php on line 155 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Undefined Constant VALID_EMAIL assumed 'VALID_EMAIL'
Hi all. I have just installed Cake PHP and am mid way writing my first app. Recently I have got into the habit of developing with NOTICES turned on, as I find it helps catch a lot of subtle errors. I am getting the following error Notice: Use of undefined constant VALID_EMAIL - assumed 'VALID_EMAIL' in /var/www/html/live/cake/dispatcher.php on line 157 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/live/cake/dispatcher.php: 157) in /var/www/html/live/cake/libs/session.php on line 154 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/live/cake/dispatcher.php:157) in /var/ www/html/live/cake/libs/session.php on line 155 Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/html/live/cake/libs/model/model_php4.php on line 1360 The model code that is triggering this is //AppModel gives you all of Cake's Model functionality class Comment extends AppModel{ var $name = 'Comment'; var $belongsTo = array('Game' => array('className' => 'Game', 'conditions'=> 'validated = 1', 'order' => '', 'limit' => '', 'foreignKey'=> 'game_id' ) ); var $validate = array('email' => "VALID_EMAIL"); } Apart from turning off notices, is there a solution to this. Everything seems to be working but I'd like to get to the bottom of why the error is occuring. Thank you in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---