Re: First time user :-D
As Marcelo hinted, $this-$name and $this-$data are not correct (hint: too many $). Also after that is resolved you will still have another issue, unless I am seeing it wrong, because it looks like you will be missing the ampersand before 'n=' in your query string as it is written now. Good luck, Milton On Feb 24, 7:52 pm, Patrick Hereford pheref...@gmail.com wrote: Hey everyone. Thanks for responding. Before I paste the full code, let me explain in more detail what I am trying to do. When someone signs up on my website, they have to have an account on another website. The website is give or take in this structurehttp://www.website.com/info.xml?r=value1y=value2with regard to 2 values I am asking for. While the user is signing up on the website, the next phase of the sign up is entering value1 and value2. I connect to the outside website upon getting these 2 values, grab the xml, turn it into an array, and check it to make sure that certain portions of the array exist (X.Y). I am unsure of the $url because I am not entirely sure how to grab the values put in the form other than that way. Now that that is out of the way, here is the full code. Model class: ?php uses('Xml'); /** * Valid Checker: Is Valid Checker * */ class Thing extends AppModel { var $name = 'value2'; var $useTable = 'things'; var $validate = array( 'value2' = array( 'rule' = array('isValidThing'), 'message' = 'Your thing is not valid!' ) ); function isValidThing($value, $params = array()) { $url = http://www.website.com/info.xml?r= .$this-$data[$this-$name]['value1'].n=.$this-$data[$this-$name]['value2']; $agent = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1; $curl_thing = curl_init(); curl_setopt($curl_thing, CURLOPT_URL, $url); curl_setopt($curl_thing, CURLOPT_HEADER, 0); curl_setopt($curl_thing, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_thing, CURLOPT_USERAGENT, $agent); $curl_result = curl_exec($curl_thing); curl_close($curl_thing); $thingResponse = new Xml($curl_result); $thingResponse-toArray(); $value = set::check($thingResponse, 'X.Y'); } ? On Tue, Feb 24, 2009 at 7:23 PM, Marcelo Andrade mfandr...@gmail.comwrote: On Tue, Feb 24, 2009 at 7:59 PM, Patrick Hereford pheref...@gmail.com wrote: Hey everyone. I am having some trouble with this model class. The error it is giving me is the following: Parse error: syntax error, unexpected ';', expecting T_FUNCTION on the last line with the bracket. Any advice? Welcome, man. For sure it's syntax error. Double check carefully your code. Specially... $this-$data[$this-$name]['value2']; Is this really correct? Best regards. -- MARCELO DE F. ANDRADE (aka eleKtron) Belem, PA, Amazonia, Brazil Linux User #221105 -- Patrick Hereford 475 Commonwealth Ave Apt. 506 Boston, MA 02215 MIT - Class of 2005 BC MBA - Class of 2008 --~--~-~--~~~---~--~~ 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: SessionComponent in API documentation
Ok thank you. I searched trac, but for 'Session API' I think, so I didn't find the ticket. Thanks again. Milton On Jan 9, 9:31 am, Dardo Sordi Bogado dardoso...@gmail.com wrote: It has been reported:https://trac.cakephp.org/ticket/5963 On Fri, Jan 9, 2009 at 12:38 AM, Luenyar luen...@gmail.com wrote: Is it intended that the SessionComponent isn't listed in the API docs under the classes section? I was looking for it today for the first time but didn't see it, so I thought I would bring it up. 'session.php' is in the files section, and of course I can review the source file no problem, but the API page is a very nice tool and at a glance I didn't notice any other Components missing there. Thanks, Milton --~--~-~--~~~---~--~~ 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: how to distinguish param and action in cakephp's URL
If you wanted to do this, you would have to setup a route for '/*' and point it to whichever controller/action is going to accept your param. So: Router::connect('/*', array('controller' = 'users', 'action' = 'view')); would allow you to get the address 'www.mysite.com/users/view/joe' by entering/linking to 'www.mysite.com/joe'. BUTthen you lose the ability to use, for example, 'www.mysite.com/ posts/' to get to 'www.mysite.com/posts/index' unless you set up a specific route for it BEFORE your '/*' route. So you would need: Router::connect('/posts', array('posts','index')); Router::connect('/announcements', array('announcements','index')); /*etc for every controller you want to access in this way*/ Router::connect('/*', array('controller' = 'users', 'action' = 'view')); Plus, maybe there are other consequences that you might find when testing it if you don't specify enough routes. See if that is what you are looking for. HTH, Milton On Jan 7, 10:02 pm, Rimoe meiyo...@gmail.com wrote: Yes, I can do these.but use the linkhttp://www.mysite.com/param1 I get a error that have no the controller of param1controller.php so, I think where should I need to set it, let the cakephp think the param1 is a param. Thanks. 2009/1/7 gearvOsh mileswjohn...@gmail.com I dont think there is a cake setting, just do this during signup. $restricted = array('users','pages','controllername'); if (in_array($usernameVar, $restricted)) { // do not allow registration } --~--~-~--~~~---~--~~ 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: how to distinguish param and action in cakephp's URL
I think you can use regex in routes, so probably you could do this. But then I think you would have to restrict user names to not have 's' as a last character. So it might be better for users if you copy/ paste/modify a bunch of routes so they don't gripe when they can't get an 's' on their user name? In my opinion I think you are trying to design an inflexible system, but ultimately it is your design choice. Good luck =) On Jan 8, 11:30 pm, Rimoe meiyo...@gmail.com wrote: Thank You for your answer.I think this is what I want to get. but I have too many controllers, this is a big task to add so many routers, and I will add more many controllers. so, is the routes.php support the Regular expression? because all of my controllers are end by 's'. for example , can I write it like this? [ Router::connect('/*s/*'); Router::connect('/*', array('controller' = 'users', 'action' = 'views', 'view')); ] Rimoe 2009/1/8 Luenyar luen...@gmail.com If you wanted to do this, you would have to setup a route for '/*' and point it to whichever controller/action is going to accept your param. So: Router::connect('/*', array('controller' = 'users', 'action' = 'view')); would allow you to get the address 'www.mysite.com/users/view/joe'by entering/linking to 'www.mysite.com/joe'. BUTthen you lose the ability to use, for example, 'www.mysite.com/ posts/ http://www.mysite.com/posts/' to get to ' www.mysite.com/posts/index'unless you set up a specific route for it BEFORE your '/*' route. So you would need: Router::connect('/posts', array('posts','index')); Router::connect('/announcements', array('announcements','index')); /*etc for every controller you want to access in this way*/ Router::connect('/*', array('controller' = 'users', 'action' = 'view')); Plus, maybe there are other consequences that you might find when testing it if you don't specify enough routes. See if that is what you are looking for. HTH, Milton On Jan 7, 10:02 pm, Rimoe meiyo...@gmail.com wrote: Yes, I can do these.but use the linkhttp://www.mysite.com/param1 I get a error that have no the controller of param1controller.php so, I think where should I need to set it, let the cakephp think the param1 is a param. Thanks. 2009/1/7 gearvOsh mileswjohn...@gmail.com I dont think there is a cake setting, just do this during signup. $restricted = array('users','pages','controllername'); if (in_array($usernameVar, $restricted)) { // do not allow registration } --~--~-~--~~~---~--~~ 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: Variating right menu based on content
Um, this might be kinda hacky, but I'm using the following currently and it functions fine for me. In my default layout: div id=sidebar echo @$this-element('sidebars/' . $this-params['controller'] . '/' . $this-params['action']); /div So I have, for example, \elements\sidebars\requests and \elements \sidebars\announcements etc. with search.ctp and view.ctp. So if I am at site/requests/search the \elements\sidebars\requests\search.ctp sidebar is rendered. If at site/requests/index, then the render fails silently and no one knows but me. Probably could be more elegant and correct with an if (file exists), I should probably do that someday. HTH, Milton On Nov 14, 8:24 am, i_Am_ToO_SeXy [EMAIL PROTECTED] wrote: Uhm... if i check for empty chunks before the layout render (for example in App_Controller)? the only code in layout will be something like ?php $something_for_layout ? it will be easier to change layout in future. am i right? On 14 Nov, 09:51, grigri [EMAIL PROTECTED] wrote: If it's the same header on every view, just call it in the layout. If, on the other hand, it's the same header in MOST views, use the chunks helper as above: some_view.ctp: ?php $chunks-begin('header'); ? This will end up in the header ?php $chunks-end(); ? your_layout.ctp: ?php if (!empty($header_for_layout)) { // A header has been defined in the view, so show it echo $header_for_layout;} else { // No header has been defined; use the default one echo $this-element('default_header');} ? elements/default_header.ctp: This is the default header Easy, huh? hth grigri On Nov 13, 5:14 pm, i_Am_ToO_SeXy [EMAIL PROTECTED] wrote: Uhm... another little problem... What about a default Header? (Same header on every view) How can i do? using AppController? On 13 Nov, 12:30, grigri [EMAIL PROTECTED] wrote: Indeed, the beforeLayout() callback doesn't seem to work. If works if you put it in afterRender() though:http://bin.cakephp.org/view/815089959 (tested this time) (same usage) hth grigri On Nov 13, 10:13 am, i_Am_ToO_SeXy [EMAIL PROTECTED] wrote: Hi grigri Thanks for the reply. I followed your suggestions but i can't get the code work. No errors but also no outputs :\ BTW i modified a little bit the layout code body div id=container div id=header?php if (isset($header_for_layout)) { echo $header_for_layout; } ?/div div id=leftbar?php if (isset($leftbar_for_layout)) { echo $leftbar_for_layout; } ?/div div id=rightbar?php if (isset($rightbar_for_layout)) { echo $rightbar_for_layout; } ?/div div id=content?php if (isset($content_for_layout)) { echo $content_for_layout; } ?/div div id=footer?php if (isset($footer_for_layout)) { echo $footer_for_layout; } ?/div /div /body Sorry for my n00bness :( On 12 Nov, 17:55, grigri [EMAIL PROTECTED] wrote: Off the top of my head, I'd suggest using a helper combined with output buffering, like this: class ChunksHelper extends AppHelper { var $chunkId = null; var $append = false; var $buffer = array(); function begin($chunkId, $append = false) { if (empty($this-chunkId)) { $this-chunkId = $chunkId; $this-append = $append; ob_start(); } } function end() { if (!empty($this-chunkId)) { $contents = ob_get_clean(); if ($this-append) { if (isset($this-buffer[$this-chunkId])) { $this-buffer[$this-chunkId] .= $contents; } else { $this-buffer[$this-chunkId] = $contents; } } else { $this-buffer[$this-chunkId] = $contents; } $this-chunkId = false; } } function beforeLayout() { $View = ClassRegistry::getObject('View'); foreach($this-buffer as $key = $value) { $View-set($key . '_for_layout', $value); } } } Then in your view: ?php $chunks-begin('rightbar'); ? This will end up in the right bar ?php $chunks-end(); ? (The code might need a bit of modifying; I just wrote it quickly, but the idea is sound. You'll definitely want to add error-checking) hth grigri On Nov 12, 4:11 pm, i_Am_ToO_SeXy [EMAIL PROTECTED] wrote: Hello all. First time posting here. I have a 3-column layout where the 3rd column is intended to be a menu. here's the code html xmlns=http://www.w3.org/1999/xhtml;
Re: Firefox form rendering problem
@Xavier, Have you ever posted any reply with any substance, advice, or value? I am consistently seeing replies by you that are nothing more than a simple/obvious/repeated question/statement with a 16 line sig. Sorry to be a jerk, just wish I could save my scroll wheel some wear and tear by not having to scroll over your useless interjections and long sig. On Nov 10, 7:03 pm, Xavier Mathews [EMAIL PROTECTED] wrote: Whats the problem tho? On 11/10/2008, Marcelo Andrade [EMAIL PROTECTED] wrote: On Mon, Nov 10, 2008 at 7:27 PM, jm [EMAIL PROTECTED] wrote: textlabel for=ArticleTitleTitle/labelinput name=data[Article] [title] type=text maxlength=255 value= id=ArticleTitle // The label tag it's not closed. Best regards. -- MARCELO DE F. ANDRADE (aka eleKtron) Belem, PA, Amazonia, Brazil Linux User #221105 [EMAIL PROTECTED] ~]# linkshttp://pa.slackwarebrasil.org/ -- B= *•*Beautiful*•* E= *•*Elegant*•* Y= *•*Young*•* O= *•*Original*•* N= *•*Natural*•* C= *•*Clever*•* E= *•*Enthralling*•* (`*•.¸ (`*•.¸ ¸.•*´) ¸.•*´) `•.¸(*)Beyoncè`s #1 Fan(*) (¸.•*(¸.•*´`*•.¸ )*•.¸) Xavier A. Mathews Student/Developer/Web-Master GG Client Based Tech Support Specialist Hazel Crest Illinois [EMAIL PROTECTED]@[EMAIL PROTECTED] Fear of a name, only increases fear of the thing itself. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Themes
I find myself terrible at picking a layout. I modified one I liked from http://www.oswd.org/ to work with my Cake site. Maybe that will help. On Nov 4, 10:36 am, Maverick [EMAIL PROTECTED] wrote: Hi all, I am a bit new to CakePHP and have gone through the demos and read a few books. Are there any downloadable themes (view templates) other than the one that comes with CakePHP. I don't want the debug info and ads for Cake everywhere. I would image that someone has a list of downloadable themes that can be used? Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: cakeapp.com
Nice idea, keep up the nice work. If you create a new screencast, in my opinion pick a slightly darker color than yellow =) On Oct 21, 10:41 am, powtac [EMAIL PROTECTED] wrote: Yes, this is the SQL Designer, a very nice one, I think.http://ondras.zarovi.cz/sql/demo/?keyword=default --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Form data from a view element
$form-create('Comment') associates the form with the 'Comment' model, but not a controller. Presumably because the 'Comments' model could be used in many or all of your controllers with $uses. The 'action' option assumes the current controller, so if you render your element in the Posts controller, the action is assumed /posts/add. url is the option you are looking for. http://manual.cakephp.org/view/183/Creating-Forms#options-url-186 Hope that helps, Milton On Sep 16, 11:31 am, Daniel [EMAIL PROTECTED] wrote: I created the form using the line: $form-create('Comment', array('action' = 'add')); Doesn't this specify that it should use the controller associated with the Comment model, i.e. the Comments controller? This is how I've done it with all of my other forms... And yes, I realize the table based layout is terrible, I'm just mocking things at the moment and didn't want to write a stylesheet to position things yet. Thanks! - Dan On Sep 16, 11:23 am, mark_story [EMAIL PROTECTED] wrote: On Sep 16, 9:11 am, Daniel [EMAIL PROTECTED] wrote: Hello, I currently have a comment box view element that I plan to embed in various places in my CakePHP application to allow users to leave comments on various aspects of the site. I'm using the form helper inside of the element to generate the form to be used to submit the data, however when I submit the data I receive only a blank screen that says 0 query took ms. I've even added debugging echoes to the controller to print the data array and I'm still just receiving a blank page with 0 query took ms. Attached below is the comment add method and the respective element code. Any help anyone can provide would be greatly appreciated, I seem to be pretty stuck! Controller code: function add() { echo ; $mrClean = new Sanitize(); echo Data . $this-data; if(!empty($this-data)) { $mrClean-clean($this-data); $currUser = $this-get_current_user(); $this-data['Comment']['user_id'] = $currUser['id']; $this-data['Comment']['isDeleted'] = 0; $targetEvent = $this-Event-find(first, array('conditions' = array('Event.id' = $this-data['Comment'] ['event_id']), 'recursive' = 1)); print_r($targetEvent); if(empty($targetEvent) || is_null($targetEvent)) { $this-Comment-invalidate('event_id', 'You have selected an invalid event.'); return; } if($this-Comment-save($this-data)) { $this-flash('Your comment has been added', '/events/view/'. $this-data['Comment']['event_id']); } else { $this-flash('An error has occured adding your comment.', '/ events'); } } } Element code: ?php echo $form-create('Comment', array('action' = 'add')); ? table class=commentsTable tr td colspan='99' class='commentSubject' Subject: nbsp;?php echo $form-input('subject', array( 'label' = false )); ? /td /tr tr tdnbsp;/td td class='commentBody' ?php echo $form-textarea('body', array( 'label' = false, 'rows' = 7, 'cols' = 80 )); ? /td /tr tr td colspan='99' class='commentSubmit' ?php echo $form-submit('Post Comment'); ? /td /tr /table ?php echo $form-hidden('event_id', array('value' = $event_id)); ? ?php echo $form-end(); ? Your form doesn't have a controller? how will it know what controller it is supposed to submit to. I would double check that you are being sent to the right URL when submitting the form. Also tables for layout make babies cry :) -Mark --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CakePHP belongsTo, associations, need help getting data from another table
More accurately, all conventions need to be followed or it will make a lot more work for you to configure it. You CAN override a lot of the assumed conventions, like if you need to connect to an existing database that you cannot modify. If you are starting from scratch, though, it is much easier for you to develop and maintain if you follow the built-in conventions. Just for example, you COULD use class EventController and var $name = 'Event', but you have to explicitly put in $uses = 'Event'. Or exclude Event from the sweet pluralizer in /config/inflections.php. And then your views folder would have to be event instead of events. In a model Event you could say $useTable = 'venues' to override the expected table name. In associations, you could use foreign_key=blah_id. Using routes you can tell Cake that /event points to events/index, /event/add = events/add. That's just to name a few. Yeah conventions! Milton On Jul 18, 8:35 pm, Parris [EMAIL PROTECTED] wrote: Ok I fixed it! All conventions need to be followed or it won't work. Related table ids need to be labeled the singularly followed by id. For example if the table is called event_categories. In events i need to have the related id for the column field called event_category_id. Also all primary keys should be called id. All tables should be plural. All model file names are singular, but controller file names are plural. Model class and variable names are singular. Controller class and variable names are plural. I think i got everything in there :). Just so anyone who has this issue in the future will know what to do! Basically associations break down if all conventions of tables and classes for cakePHP aren't followed. Thats how it was for me at least. On Jul 18, 9:49 am, Parris [EMAIL PROTECTED] wrote: That didn't seem to make a difference... I closed my other post about cake not letting me make my controller name plural and reposted it here. I feel like this is a related issue. I have another model and controller that Event belongsTo and that seems to work fine. I think there is something wrong with the way I created something. To make this all work right now I have to call my model event.php (Event) and my controller event_controller.php(Event_Controller) or else cake will tell me the following: Missing Controller Error: EventController could not be found. Error: Create the class EventController below in file: app/ controllers/ event_controller.php ?php class EventController extends AppController { var $name = 'Event'; } ? My Event Model (event.php in /models): ?php class Event extends AppModel { var $name = 'Event'; var $useTable = 'events'; var $belongsTo = array( 'GalleryCategory' = array( 'className' = 'GalleryCategory', 'foreignKey' = 'id', 'associationForeignKey' = 'gallery_id', 'joinTable' = 'gallery_categories' ), 'EventCategory' = array( 'className' = 'EventCategory', 'foreignKey' = 'id', 'associationForeignKey' = 'cat_id', 'joinTable' = 'event_categories' ) ); } ? Events Controllers (events_controller.php in /controllers): ?php class EventsController extends AppController { var $name = 'Events'; function index() { $this-set('events', $this-Event-findAll()); } } ? Look to my previous post for the info on event_categories. I was able to rename that controller and make it plural; however, it wont let me with the event controller. I have made soo many searches on this. Read and reread all the conventions. I have no idea where to turn. On Jul 18, 1:07 am, grigri [EMAIL PROTECTED] wrote: Use a `belongsTo`, not a `hasOne`. On Jul 18, 3:52 am, Parris [EMAIL PROTECTED] wrote: So I have a MVC for Events and Event Categories. I am trying to have the name of the category appear on the event page. I am associating events as belonging to event categories with a field called cat_id. I am able the retrieve the tables, but for some reason the event category part of the array ends up empty. Visually I am trying to make it look something like: Concert: Annual Event Where Concert is equal to a cat_name which is associated by cat_id(in the event table) = id(in the event categories table) and Annual Event is the event_title (in the event table). Also the word concert would be linked to show a category view Getting data from the event table is no problem. I used print_r($event[0]) to show data from the first entry: [code]Array ( [Event] = Array ( [id]