Re: Javascript Helper modification. Opinions, please.
Perfect!! Thanks, Mark :-) On Jul 11, 12:05 pm, mark_story wrote: > This feature was already implemented in 1.3 for Html::script(). It > has a 'once' option that defaults to true. As long as you always use > the same name for a file it will only be included once. > > -Mark > > On Jul 9, 3:05 pm, Geoff Oliver wrote: > > > > > Hello, > > > I've been working with Cake for a few years and I really like it. > > Lately, I've run into a bit of a problem with the way that the > > Javascript Helper handles some things. Specifically, the "link" > > function and it's $inline parameter. The issue I'm having is this... > > > In an element, I am linking in javascript files, but NOT inline - > > $javascript->link('prototype',false); > > In the main layout, I am linking in javascript files, but inline - > > $javascript->link('prototype'); > > > The problem is that prototype is being included twice. The real > > problem is that I am actually including it twice, but I have no way of > > knowing at that earlier point (in the element) whether it will be > > included later (in the layout) or if it's been included yet, and I > > need it for things to happen in the element, so I don't think I have > > any other choice. > > > I understand the behavior is because if you don't pass the $inline > > parameter as false then the Javascript Helper just returns a
Re: SEO URL's (Slug?)
check out this great plugin I've started using http://github.com/mariano/syrup On Jun 22, 9:53 am, Sam Sherlock wrote: > in your table have a field `title` the behaviour converts this to a slug and > saves that in the table field named `slug` > > you can set some basic options in the actAs array config - check the source > of the slug behaviour for options like separator and overwriting > > - S > > On 22 June 2010 14:21, Shaz wrote: > > > Anyone have any documentation on the CakePHP slug? Can't seem to find > > much on it - just trying to get my URL's all nice and pretty for > > google without having to mess with Routing / creating seperate helpers > > and so forth to get 'em tarted up. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.comFor > > more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Cakephp and XAMPP installation nightmare, Can't get cake to understand root
1) XAMPP 1.7.3 setup and working http://localhost/xampp/ -> success 2) Unpacked cake1.3.2, installed under XAMPP -> htdocs -> cake1.3.2 (folder) Checked setup http://localhost/cake1.3.2/ -> success Your tmp directory is writable. The FileEngine is being used for caching. To change the config edit APP/config/core.php Your database configuration file is present. Cake is able to connect to the database. 3) Trying to Implement IBM tutorial Part1 Created MySQL tabel 'Users' under cake1.3.2\app\models, created user.php under cake1.3.2\app\controllers, created users_controller.php, with action registration under cake1.3.2\app\view\users, created registration.ctp 4) now http://localhost/cake1.3.2/app/views/users/registeration throws an err Error: ViewsController could not be found. Error: Create the class ViewsController below in file: app\controllers \views_controller.php This is where I am stuck for a week now, can’t get passed this screen, tried several solutions but still cant get this to work..really frustrated. please help! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Problems with blog tutorial Warning (512): SQL Error: 1064:
Umm yeah, your right it was not in the blog tutorial and I have no idea why or where my head was at... thanks. Blaine On Jul 10, 1:41 am, nurvzy wrote: > It's possible what you meant to do was this: > > $this->Post->id = $id; > > Because you're doing a blind read() after the fact. If you're going > to remove that line you'll need to be sure to pass in the id to read() > like so: > > $this->Post->read(null, $id); > > Hope that helps, > Nick > > On Jul 9, 11:25 pm, nurvzy wrote: > > > Indeed, the error is because you have $this->Post->edit($id); in your > > controller. If the method name is not found cake sends the method > > name as an SQL query by default. Simply remove that line and you > > should be all set. > > > I encourage you to make sure you type in your controller code as it's > > laid out for you in the tutorial. I'm not sure where or who told you > > to type in $this->Post->edit($id); in the controller, as its not in > > the tutorial: > > >http://book.cakephp.org/view/1540/Editing-Posts > > > Hope that helps, > > Nick > > > On Jul 9, 4:13 pm, BlaineRumsey wrote: > > > > Hello, I am new to cake and I am trying to complete the blog tutorial > > > in the manual for 1.3 for getting started. I am at the edit post > > > section and I am having a problem. When I click edit I get and sql > > > syntax error. > > > > 1064: You have an error in your SQL syntax; check the manual that > > > corresponds to your MySQL server version for the right syntax to use > > > near 'edit' at line 1 > > > > the output sql query is : > > > > SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, > > > `Post`.`modified` FROM `posts` AS `Post` WHERE `Post`.`id` = 1 LIMIT 1 > > > > which when pasted into the sql cmd editor in myadmin comes out fine no > > > errors. > > > > can anyone help me out here? > > > > details: > > > > php 5.2.4 > > > mysql 5.0.24a > > > > here is my edit function > > > > function edit($id){ > > > $this->Post->edit($id); > > > if(empty($this->Post->data)){ > > > $this->data = $this->Post->read(); > > > }else{ > > > if($this->Post->save($this->data)){ > > > $this->Session->setFlash('Your post has > > > been updated.'); > > > $this->redirect(array('action'=>'index')); > > > } > > > } > > > } > > > > I appreciate the help. > > > > BlaineRumsey Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Validation problem
Hi, I have an odd validation issue I can't work out. I have the following form built using the form helper; == Form->create('Account');?> Form->input('username', array('id' => 'global_accounts_Username', 'div' => 'v input', 'label' => array('text' => 'Username', 'class' => 'label'))); ?> Can be any length but only contain letters and numbers. No spaces, hyphens or underscores allowed. Form->input('password', array('id' => 'global_accounts_Password', 'div' => 'v input', 'label' => array('text' => 'Password', 'class' => 'label'), 'after' => 'Time needed to crack password, ')); ?> Can contain any type of character but must be over 6 characters in length. It is recommended to use punctuation or a full sentence. Form->input('email', array('id' => 'global_accounts_Email', 'div' => 'v input', 'label' => array('text' => 'E-mail', 'class' => 'label'))); ?> Must exist and be accessible, a conformation e-mail will be sent to this address as well as any account notifications. Form->input('first_name', array('id' => 'global_accounts_FirstName', 'div' => 'v input', 'label' => array('text' => 'First name', 'class' => 'label'))); ?> If you are an individual please enter your first name, only letters are allowed. Form->input('second_name', array('id' => 'global_accounts_SecondName', 'div' => 'v input', 'label' => array('text' => 'Second name', 'class' => 'label'))); ?> If you are an individual please enter your second name, only letters are allowed. Form->input('company_name', array('id' => 'global_accounts_CompanyName', 'div' => 'v input', 'label' => array('text' => 'Company name', 'class' => 'label'))); ?> If you are a business please enter your business name, only letters, numbers and spaces are allowed. Form->input('terms_accepted', array('id' => 'global_accounts_TermsAccepted', 'div' => 'v input', 'label' => array('text' => 'Accept terms', 'class' => 'label_left'))); ?> To open an account you MUST agree to these terms and conditions and Privacy policy Form->end(__('Register account', true));?> == This is validated by the following validation rules in the 'Account' model. == var $validate = array( 'username' => array( 'rule' => 'alphaNumeric', 'message' => 'Usernames can only contain letters and numbers.', 'allowEmpty' => false ), 'password' => array( 'rule' => array('minlength', 6), 'message' => 'Passwords must be six (6) characters or more.', 'allowEmpty' => false ), 'email' => array( 'rule' => 'email', 'message' => 'Email must be valid.', 'allowEmpty' => false ), 'first_name' => array( 'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a- zA-Z])?[a-zA-Z]*)*$'), 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'second_name' => array( 'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a- zA-Z])?[a-zA-Z]*)*$'), 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'company_name' => array( 'rule' => array('custom' => '(\w(\s)?)+'), 'message' => 'Company names can only contain letters, numbers and spaces.' ), 'terms_accepted' => array( 'rule' => array('comparison', '!=', '>0'), 'required' => true, 'message' => 'You must agree to the terms and conditions and privacy policy.', 'on' => 'create' ) ); == The problem is whenever the form is submitted I get this error back; == Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 2550] Warning (512): Could not find validation handler for first_name [CORE/ cake/libs/model/model.php, line 2573] Warning (512): Could not find validation handler for second_name [CORE/cake/libs/model/model.php, line 2573] Warning (512): Could not find validation handler for company_name [CORE/cake/libs/model/model.php, line 2573] == I don't know why it doesn't like these fields, they are named the same in the database, form and validation rule let it doesn't seem to like it. The data is saved correctly to the database when supplied so that isn't an issue. Does anyone know a way around this? Thanks, Felix Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit th
read REST API
Hi, how i can read like youtubes api xml or json with cake is there a method which i can use or i have to write it by my self. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Wrapping form elements inside ?
Thank you for your help. On Jul 10, 8:07 pm, red wrote: > Form->input('field', array('div' => false)); ?> p> > > or: > > Form->input('field', array('div' => false, 'before' > => '', 'after' => '')); ?> > > On 10 Lip, 08:48, "matzeh...@googlemail.com" > > wrote: > > Hi, > > > with the option 'div'=>false you can disable the surrounding div > > Container. > > But adding a p with the form helper.. hm.. > > > On 10 Jul., 01:27, saidbakr wrote: > > > > Hi > > > > How could IWrappingforms Elements inside p tag instead of div tag? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Js helper advice needed
This was an issue I ran into while doing an ajax shopping cart. The form element that is returned via AJAX needs to have echo $js- >writeBuffer() in it as well. Alternatively, you can specify that the jshelper not buffer the javascript and instead output it as you call it (AjaxHelper style). That solved my issue, and hope it helps you, NIck On Jul 11, 4:22 am, Jeremy Burns wrote: > I have a view that contains an element for logging in. The key bits > are inside a div with an id of 'login'. The login form's submit button > is created using the Js helper: > > echo $this->Js->submit( > 'Login', > array( > 'update' => '#login', > 'url' => array( > 'controller' => 'users', > 'action' => 'login' > ), > 'id' => 'sbt_login' > ) > ); > > I have given the button an id so that any Javascript created will > reference that, rather than a random number. > > When the view is rendered, this is the HTML for the form: > > > Login/Register > > > > > Username > id="UserUsername" /> > Password > id="UserPassword" /> > > > > > > > Using $this->Js->writeBuffer, the following script is added to the > body: > > > // $("#sbt_login").bind("click", function (event) {$.ajax({data:$ > ("#sbt_login").closest("form").serialize(), dataType:"html", > success:function (data, textStatus) {$("#login").html(data);}, > type:"post", url:"\/users\/login"}); > return false;});}); > //]]> > > > So far so good. Clicking the 'Log in' button triggers the login > methods of the users controller using ajax and refreshes the contents > of the 'login' div. > > Assuming that the login failed, the login form is redrawn, along with > an error message. The HTML is exactly the same. This time however, > clicking the login button does not use ajax, so the whole page is > replaced with just the contents of the login div. > > One way around this is to not include the login submit button in the > HTML that is refreshed via ajax. The problem with this is that if the > login is successful, the login button should disappear, which of > course it won't. > > I could do all of this with straightforward javascript, but that sort > of misses the point of having the Js helper. > > What am I doing wrong, what is the right way to do this and are there > any examples out there? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Javascript Helper modification. Opinions, please.
This feature was already implemented in 1.3 for Html::script(). It has a 'once' option that defaults to true. As long as you always use the same name for a file it will only be included once. -Mark On Jul 9, 3:05 pm, Geoff Oliver wrote: > Hello, > > I've been working with Cake for a few years and I really like it. > Lately, I've run into a bit of a problem with the way that the > Javascript Helper handles some things. Specifically, the "link" > function and it's $inline parameter. The issue I'm having is this... > > In an element, I am linking in javascript files, but NOT inline - > $javascript->link('prototype',false); > In the main layout, I am linking in javascript files, but inline - > $javascript->link('prototype'); > > The problem is that prototype is being included twice. The real > problem is that I am actually including it twice, but I have no way of > knowing at that earlier point (in the element) whether it will be > included later (in the layout) or if it's been included yet, and I > need it for things to happen in the element, so I don't think I have > any other choice. > > I understand the behavior is because if you don't pass the $inline > parameter as false then the Javascript Helper just returns a
Saving data in a component class
hi, i created a component "imageComponent" with a function that uploads and resizes images. the components functions is called in my users_controller. it works (thank god). now i wanna save the path, where the profile picture is saved, in my database.. i tried to save the path in my component with $data['User']['image_path']=$folderName."/".$filename; Save the data $this->User->save($data); thats the lovely error that cakephp is throwing Notice (8): Undefined property: ImageComponent::$User [APP\controllers \components\image.php, line 105] Code | Context Fatal error: Call to a member function save() on a non-object in F:\abc \Entwicklung\xampp\htdocs\muh\app\controllers\components\image.php on line 105 thats 105: $this->User->save($data); my component: class ImageComponent extends Object { function upload_image_and_thumbnail($data, $datakey, $imgscale, $thumbscale, $folderName, $square) { if (strlen($data['User']['name'])>4){ $error = 0; $tempuploaddir = "img/temp"; // the /temp/ directory, should delete the image after we upload $biguploaddir = "img/profilepics/big/".$folderName; // the /big/ directory $smalluploaddir = "img/profilepics/small/".$folderName; // the / small/ directory for thumbnails // Make sure the required directories exist, and create them if necessary if(!is_dir($tempuploaddir)) mkdir($tempuploaddir,true); if(!is_dir($biguploaddir)) mkdir($biguploaddir,true); if(!is_dir($smalluploaddir)) mkdir($smalluploaddir,true); $filetype = $this->getFileExtension($data['User']['name']); $filetype = strtolower($filetype); if (($filetype != "jpeg") && ($filetype != "jpg") && ($filetype ! = "gif") && ($filetype != "png")) { // verify the extension return; } else { // Get the image size $imgsize = GetImageSize($data['User']['tmp_name']); } // Generate a unique name for the image (from the timestamp) //$id_unic = str_replace(".", "", strtotime ("now")); $filename = $folderName; settype($filename,"string"); $filename.= "."; $filename.=$filetype; $tempfile = $tempuploaddir . "/$filename"; $resizedfile = $biguploaddir . "/$filename"; $croppedfile = $smalluploaddir . "/$filename"; if (is_uploaded_file($data['User']['tmp_name'])) { // Copy the image into the temporary directory if (!copy($data['User']['tmp_name'],"$tempfile")) { print "Error Uploading File!."; exit(); } else { /* * Generate the big version of the image with max of $imgscale in either directions */ $this->resize_img($tempfile, $imgscale, $resizedfile); if($square) { /* * Generate the small square version of the image with scale of $thumbscale */ $this->crop_img($tempfile, $thumbscale, $croppedfile); }
php-ids in cakephp - 1.3
hi i want use PHPIDS (php-ids.org) in cakephp 1.3 what i am must to do? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Having Issue when submitting form to plugin controller action
Hi Guys, I am a 3+ years old in cakephp and facing a somewhat strange issue with submitting a form to plugin controller's action (i am using plugin first time). After trying different known things i am posting this one. Going straight into the matter here is the form in my "forum" plugin's -> search_controller.php's -> index view: create("Search", array('url'=>array('controller' => 'search', 'action' => 'index','plugin'=>'forum'), 'id'=>'searchFormMain')); ?> As i am submitting this form to "index" action of search controller of forum plugin, the following code does print nothing: public function index($type='') { if(!empty($this->data)) { pr($this->data); die; } } While if i try the same code within beforeFilter of the same controller i.e. search_controller.php it works well and prints as follows: Array ( [Search] => Array ( [keyword] => Hello Forum ) ) And finally here is the beforeFilter code (of search_controller.php): public function beforeFilter() { parent::beforeFilter(); if(!empty($this->data)) { pr($this->data); } } Fyi, it does not matter if i comment out "parent::beforeFilter();" or event disable $uses of my controller (if they look doubtful to you) the result is same i.e. the control is not going in to "index" action in the case of form submit while is working fine in the case of page call. The url/action to page is http://localhost.rfdf.org/forum/search/index. If i call the url directly is loads the form fine but when i submit it never get into the "index" action of the controller thus no view rendered. I have been trying to find a way out of this for last 3+ hours now but no success. I would appreciate any help in solving this puzzle. Thanks, Arvind. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Baking with 1.3.x
I can't seem to bake a controller on 1.3.2. Windows enviro, I set it up and was baking 1.2.x just fine I have my cake versions inside wamp/libs/1.2.6 /1.3.2 Simply changed in my system environment variables from D:\wamp\www\libs\1.2.6\cake\console; to D:\wamp\www\libs\1.3.2\cake\console; Bake models just fine, try to bake a controller it goes thru the normal steps then at the end I get --- Baking CommentsController --- Would you like to build your controller interactively? (y/n) [y] > n Would you like to create some basic class methods (index(), add(), view(), edit())? (y/n) [n] > y Would you like to create the basic class methods for admin routing? (y/n) [n] > y PHP Fatal error: Class 'Comment' not found in D:\wamp\www\libs\1.3.2\cake\libs\ class_registry.php on line 141 Fatal error: Class 'Comment' not found in D:\wamp\www\libs\1.3.2\cake\libs\class _registry.php on line 141 Any ideas anyone? Thanks Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Cake 1.2 / 1.3: how to Instantiate helper with options?
Thanks for your reply, Nick. Nice to see a familiar face here, too :) I could swear the last time I looked through the Book, it wasn't there. But now it is. I solved it with this bit of widom from the 1.3 section: http://book.cakephp.org/view/1616/x1-3-improvements Although I would have liked to set these options in the AppController, and have it filter through site-wide, I suppose once per form ain't so bad. * On Jul 10, 7:38 am, nurvzy wrote: > As far as I know you can't set the default input options at the > constructor level. Although I haven't dug into the code in a while to > make sure of that. If I'm wrong, someone will correct me. > > You can go the MyFormHelper class route, which may be the *best* > option IMHO. Just overwrite the create function calling the > parent::create() with a set an array_merge of default options you > want. > > class MyFormHelper extends FormHelper { > var $defaults = array('inputDefaults' => array('div' => false)); > > function create($model = null, $options = array()){ > parent::create($model, array_merge($this->defaults, $options)); > } > > } > > Simple as that. > > Or you can instead use an element, pass in an array as options to > array_merge with your default options for your form. That is a trick > I like to use often with pagination options and links. > > Another option, could be defining a $default_form_options in your > app_controller than you set and use for every form create (adjusting > as needed). > > Example: > //app_controller beforeFilter > $this->set('default_form_options', array('inputDefaults' => > array('div' => false))); > > //view > $this->Form->create('Model', array_merge($default_form_options, > array('url' => 'some_where'))); > > You get the idea... > > Hope that helps, > Nick Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en