Circularity with beforeFilter calling redirect
I've read some threads that cover my situation, but they end in solutions that don't work. If a user is not logged in, I want all URLs a user might try to redirect to the login page. I thought I could do class AppController extends Controller { function beforeFilter() { if(!$this-isLoggedIn()) { $this-redirect('/user/login'); } } } But this leads to a circular reference, because redirect() leads to a second call to this beforeFilter(), ad infinitum. I see two ways around it 1) access whether the requested URL is '/user/login' and make an exception not to redirect in this case -- how can I do this in Cake? 2) Are new instances of AppController created with each redirect()? If the same instance is re-used, then I can set a member variable to let me know I've entered once, and then I can protect against re-entry. While I'm at it, I'll save the user's requested URL as well, and redirect them there after they login, as a super-helpful convenience. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Looking for examples
Hello, I am completely new to CakePHP and somewhat new to web development in general. I am trying to figure out what the best setup is for web pages that do not fall within the typical Cake concepts. Any examples or somewhat extended tutorials going beyond the one table CRUD pages would be great. To start with, I need a logon page. There is not really a model (database table) backing up that page so I am more or less stuck, unless of course, I just put 'normal' php code up for that page. I am just not sure that is the way to do it. Any guidance or references would be greatly appreciated. Thanks, Peter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to avoid the 'EDIT' action 'ADD' a new record when you changed PK.
Great - info to answer this and a few other questions. I'll certainly read the Post-Redirect-Get stuff, and make use of the $fieldList parameter before pondering further. Olivier - that´s a nice technique, I wonder which other web experiences use can be 'enhanced' in that way ;o) Cheers, AD7six --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
Isn't there going to be some kind of User model behind that page? If not, how do you authenticate their login? You would want to do this the same as any other function, have a User model with a username and password, a UsersController with a login function, and a users/login.thtml View. In the UsersController login function it checks if data has been submitted, if not then the login view is displayed. If data has been submitted it is validated (ie check if a User model exists with the provided username/password), and either the login view is shown with an error (invalid credentials), or the page is redirected to whatever the authenticated user should see. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
This should get you started...http://manual.cakephp.org/chapter/19On 5/24/06, Grant Cox [EMAIL PROTECTED] wrote:Isn't there going to be some kind of User model behind that page?If not, how do you authenticate their login?You would want to do this the same as any other function, have a Usermodel with a username and password, a UsersController with a loginfunction, and a users/login.thtml View.In the UsersController login function it checks if data has been submitted, if not then the loginview is displayed.If data has been submitted it is validated (iecheck if a User model exists with the provided username/password), andeither the login view is shown with an error (invalid credentials), or the page is redirected to whatever the authenticated user should see. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Circularity with beforeFilter calling redirect
that should be: logged in users can not* access the login page. As I´m here again anyway: 1) It´s not really a good idea to define a general method and include specific exlusions - hence the suggestion to override in the specific circumstance. 2) a new controller instance is created for each request. Note that a new instance of the appController is never* created in normal circumstances - an instance of your specific controller is created, which inherits it´s behaviour and methods (if not overriden) from the appController, which inherits it´s behaviour and methods (if not overriden) from the controller defined in the cake libs. You can know where a page request came from the referrer ($this-referrer(DefaultUrlIfNoReferrer);) Cheers, AD7six * AFAIK error messages (missing controller etc.) use an instance of the appController. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
Gentlepeople, Thanks for your prompt and to the point replies. I will look into the info you provided. I also found the rdBloggery example which seems relevant for what I am trying to do. I guess I will have to get used to the required 1-1-1-1 mapping between controller, model, view and database table. I am just not sure it will always work out. E.g. what if I decided, for whatever reason, to store user authentication in a local encrypted file. Would I be able to get that working within the CakePHP framework? Another thing I am wondering about is if I decided to expose some of the features of what I am building through a web service (e.g. SOAP). How could I organize the code so that both my web site and web service implementation are able to reuse the core of the business logic code. Thanks, Peter John Zimmerman [gmail] wrote: This should get you started... http://manual.cakephp.org/chapter/19 On 5/24/06, Grant Cox [EMAIL PROTECTED] wrote: Isn't there going to be some kind of User model behind that page? If not, how do you authenticate their login? You would want to do this the same as any other function, have a User model with a username and password, a UsersController with a login function, and a users/login.thtml View. In the UsersController login function it checks if data has been submitted, if not then the login view is displayed. If data has been submitted it is validated (ie check if a User model exists with the provided username/password), and either the login view is shown with an error (invalid credentials), or the page is redirected to whatever the authenticated user should see. --=_Part_164899_21213239.1148455941820 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This should get you started...brbra href=http://manual.cakephp.org/chapter/19;http://manual.cakephp.org/chapter/19/abrbrdivspan class=gmail_quoteOn 5/24/06, b class=gmail_sendernameGrant Cox/b lt; a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/agt; wrote:/spanblockquote class=gmail_quote style=border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;brIsn't there going to be some kind of User model behind that page?nbsp;nbsp;If brnot, how do you authenticate their login?brbrYou would want to do this the same as any other function, have a Userbrmodel with a username and password, a UsersController with a loginbrfunction, and a users/login.thtml View.nbsp;nbsp;In the UsersController login brfunction it checks if data has been submitted, if not then the loginbrview is displayed.nbsp;nbsp;If data has been submitted it is validated (iebrcheck if a User model exists with the provided username/password), andbreither the login view is shown with an error (invalid credentials), or brthe page is redirected to whatever the authenticated user should see.brbrbrbr --=_Part_164899_21213239.1148455941820-- --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
Hi Peter, A gentle hint: search before asking. I guess I will have to get used to the required 1-1-1-1 mapping between controller, model, view and database table. That's not really true, the bit relavent to what you are asking is that you can have any number (including 0) of Models used by a controller; You can also create Models which don´t use a database and use other sources. This tool is pretty useful, although the wiki results are still broken: http://www.cakephp.org/search You´ll probably find that no matter what circumstance you can think of, by searching you will find it is either already included in Cake, is planned for, or is expandable to include your requirements in a scalable not-a-hack kind of way. The IRC is a good place to pick up hints if you can´t find an answer pretty quicky to concept type questions. Cheers, AD7six --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Variables in routes
First I would like to say that I am really enjoying using cake. It makes site development much easier and more fun. I am using cake 1.0.xx, PHP 4.4.3-dev (PHP 5 available, by default used for .php5 extension) I am trying to figure out how to handle my url structure. I am developing a site for an annual conference. Since most of the pages for each conference will be the same, I want to do something like: /conf-1/presentations/ /conf-1/presentations/view/1 /conf-2/presentations/ ... and so on, where conf-? is a variable that I pass to the appropriate controller, so it knows which conference to retrieve the information for. What I would really like is to match /conf-(\d)+/, and use that as the first param. So for instance, /conf-1/presentations/view/1 would call PresentationsController::view( $conf, $id ) with $conf = 'conf-1' and $id = 1 I hope someone can tell me a way to do this, or a better way to do what I want to do. I also apologize in advance if this has been covered before. I have done a search, and found the tantalizing reference to dealing with i18n by AD7six, e.g. in routes.php: $Route-connect ('/en/:controller/:action/*', array('controller'='pages', 'action'='view', language=en)); But here the languages are hard coded. Thanks in advance for any help. -- Ryan Ginstrom --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Variables in routes
Hi Ryan! Just take a look into Dispatcher::parseParams() implementation. In Your app/config/routes.php You can access instance of Router as $route, url as $from_url and (by dispatcher) not-touched superglobals $_GET and $_POST. So: if You're able apply to string some regexp matches, You can access above mentioned variables in Your routes.php file and change everything You want - in Your case You have to change content of variable $from_url from '/conf-1/presentations/view/1' to '/presentations/view/conf-1/1' in Your app/config/routes.php file. Then You don't have to specify any route for Your controller, as then will be dispatched correct automatically. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
enabling $recursive only in some models
Let's say that I have the following db schema: Model Order var $belongsTo = 'User'; var $hasMany = 'Donetask'; var $hasOne = 'Ordernote'; var $recursive = 2; Model User var $hasMany = 'Order,Donetask'; Model Donetask var $belongsTo = 'User,Task,Order'; (and many others that I skip...) If I perform a find on Order for order Id = 04 I got a lot of details (nested arrays), wich is fine. But let's say I need to go deep in with recursive only on Donetask (to have the info from Task) and not from User (I don't need to know the full list of orders saved by the user). Is there a way to specify this or in the models or in the single find method? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
Another typo (I hope last one): Snippet from file /usr/local/etc/cherokee/www.example.com : has to be Snippet from file /usr/local/etc/cherokee/sites-available/www.example.com : --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Nice URLs and webservers other then apache
Hi all! From CakePHP manual and wiki it looks we have no other choice then apache webserver, if we want to have nice URLs. Don't worry, it is not true. There are couple of options and I want to share with You configuration snippets for 'nice URLs' with production install of CakePHP at 2 nice webservers. I will assume You have Cherokee webserver or lighttpd installed on Your system and it works with php (both of them are able run php as cgi or fastcgi). Let's prepare: Sample directory structure: # Here is CakePHP distro (dirs 'app', 'cake', 'vendors'). # Files .htaccess and index.php arent' needed. /usr/local/lib/cakephp # Here are copied subdirectories of 'app' directory for example virtual host. # Files app/.htaccess, app/index.php and app/webroot/.htaccess arent' needed. # HERE Your app will live (controllers, models...), if You don't touched bootstrap.php ;) /usr/local/www/servers/www.example.com/app Change constant CAKE_CORE_INCLUDE_PATH in file /www/servers/www.example.com/app/webroot/index.php to define('CAKE_CORE_INCLUDE_PATH', '/usr/local/lib/cakephp'); === Cherokee Web Server from http://www.0x50.org/ Snippet from file /usr/local/etc/cherokee/www.example.com : #- Server www.example.com { DocumentRoot /www/servers/www.example.com/app/webroot ... Directory /css, /files, /img, /js { Handler common ... } Directory / { Handler redir { Rewrite /(.*)$ /index.php?url=$1 } } ... } #- === lighttpd from http://www.lighttpd.net/ Snippet from file /usr/local/etc/lighttpd.conf : #- server.modules = ( mod_rewrite, mod_simple_vhost ... ) ... simple-vhost.server-root = /usr/local/www/servers/ simple-vhost.default-host = www.example.com simple-vhost.document-root = /app/webroot/ ... url.rewrite-once = ( /(.*)\.(.*) = $0, /(css|files|img|js)/ = $0, ^/([^.]+)$ = /index.php?url=$1 ) ... #- Enjoy! :) P.S. - if You have CakePHP worked on other web server with some rewrite trick, let us know, please - if You speak English better then me, write some nice wiki article about it, please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
Well I'm a bit of a noob, but what is: var $helpers = array('link'); Shouldn't it be: var $helpers = array('Html'); On May 23, 2006, at 10:35 PM, modfather wrote: I am attempting to add a Global menu to the layout file (thinking this is the appropriate place to put it). I tried the css-menu tutorial available in the wiki and it failed. I then again scaled back to test the following; class AppController extends Controller { var $helpers = array('link'); }//saved in app/app_controller.php class LinkHelper extends Helper { function makeEdit() { echo linkhelper; } }//saved as link.php in helpers directory. the created this as test.thtml in the elements directory. line 1 ?php echo $link-makeEdit() ? i then inserted ?php echo $this-renderElement('test'); ? in my views/layoutsdefault.thtml I have tried a few variations of this but i get a fatal error Call to a member function on a non-object in /cake/app/views/elements/test.thtml on line 1. would someone like to point me in right direction as to what i am doing wrong. cheers. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
I've done this a couple of different ways. When I had a static menu, I put this into my layout: ?php echo $this-renderElement('menu')? I saved menu.thtml in my elements folder ul liMenu Item 1/li liMenu Item 2/li /ul When I needed dynamic content, my menu.thtml looked like this: ul ?php foreach($menu as $pages): ? li?= $html-link($pages['Webpage']['name'], /webpages/{$pages['Webpage']['name']}); ?/li ?php endforeach; ? /ul and put this in my controller: $this-set('menu', $this-Webpage-findAll()); The trick with this is to make sure you set 'menu' in your controller for any function that uses a layout that calles renderElement('menu'). You could probably also test for $menu and only render it if menu has been set. There are probably other/better ways to do this, but maybe this will help you get started. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Passing variables
Call me stupid. I was setting the photo_id immediately preceding this requestAction from Session variables. And duh! With debugging turned on that screws session stuff up! Anyway, something I did learn that I was totally oblivious to is that you can pass stuff in the array $extra when requesting an action and that puts it in $this-params for the action you requested to use. Am I a nerd or what? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Nice URLs and webservers other then apache
Hi all! From CakePHP manual and wiki it looks we have no other choice then apache webserver, if we want to have nice URLs. Don't worry, it is not true. There are couple of options and I want to share with You configuration snippets for 'nice URLs' with production install of CakePHP at 2 nice webservers. I will assume You have Cherokee webserver or lighttpd installed on Your system and it works with php (both of them are able run php as cgi or fastcgi). Let's prepare: Sample directory structure: # Here is CakePHP distro (dirs 'app', 'cake', 'vendors'). # Files .htaccess and index.php arent' needed. /usr/local/lib/cakephp # Here are copied subdirectories of 'app' directory for example virtual host. # Files app/.htaccess, app/index.php and app/webroot/.htaccess arent' needed. # HERE Your app will live (controllers, models...), if You don't touched bootstrap.php ;) /usr/local/www/servers/www.example.com/app Change constant CAKE_CORE_INCLUDE_PATH in file /www/servers/www.example.com/app/webroot/index.php to define('CAKE_CORE_INCLUDE_PATH', '/usr/local/lib/cakephp'); === Cherokee Web Server from http://www.0x50.org/ Snippet from file /usr/local/etc/cherokee/www.example.com : #- Server www.example.com { DocumentRoot /www/servers/www.example.com/app/webroot ... Directory /css, /files, /img, /js { Handler common ... } Directory / { Handler redir { Rewrite /(.*)$ /index.php?url=$1 } } ... } #- === lighttpd from http://www.lighttpd.net/ Snippet from file /usr/local/etc/lighttpd.conf : #- server.modules = ( mod_rewrite, mod_simple_vhost ... ) ... simple-vhost.server-root = /usr/local/www/servers/ simple-vhost.default-host = www.example.com simple-vhost.document-root = /app/webroot/ ... url.rewrite-once = ( /(.*)\.(.*) = $0, /(css|files|img|js)/ = $0, ^/([^.]+)$ = /index.php?url=$1 ) ... #- Enjoy! :) P.S. - if You have CakePHP worked on other web server with some rewrite trick, let us know, please - if You speak English better then me, write some nice wiki article about it, please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
Hi 100rk, why don't you do a new wiki page for that ? olivvv 100rk wrote: Hi all! From CakePHP manual and wiki it looks we have no other choice then apache webserver, if we want to have nice URLs. Don't worry, it is not true. There are couple of options and I want to share with You configuration snippets for 'nice URLs' with production install of CakePHP at 2 nice webservers. I will assume You have Cherokee webserver or lighttpd installed on Your system and it works with php (both of them are able run php as cgi or fastcgi). Let's prepare: Sample directory structure: # Here is CakePHP distro (dirs 'app', 'cake', 'vendors'). # Files .htaccess and index.php arent' needed. /usr/local/lib/cakephp # Here are copied subdirectories of 'app' directory for example virtual host. # Files app/.htaccess, app/index.php and app/webroot/.htaccess arent' needed. # HERE Your app will live (controllers, models...), if You don't touched bootstrap.php ;) /usr/local/www/servers/www.example.com/app Change constant CAKE_CORE_INCLUDE_PATH in file /www/servers/www.example.com/app/webroot/index.php to define('CAKE_CORE_INCLUDE_PATH', '/usr/local/lib/cakephp'); === Cherokee Web Server from http://www.0x50.org/ Snippet from file /usr/local/etc/cherokee/www.example.com : #- Server www.example.com { DocumentRoot /www/servers/www.example.com/app/webroot ... Directory /css, /files, /img, /js { Handler common ... } Directory / { Handler redir { Rewrite /(.*)$ /index.php?url=$1 } } ... } #- === lighttpd from http://www.lighttpd.net/ Snippet from file /usr/local/etc/lighttpd.conf : #- server.modules = ( mod_rewrite, mod_simple_vhost ... ) ... simple-vhost.server-root = /usr/local/www/servers/ simple-vhost.default-host = www.example.com simple-vhost.document-root = /app/webroot/ ... url.rewrite-once = ( /(.*)\.(.*) = $0, /(css|files|img|js)/ = $0, ^/([^.]+)$ = /index.php?url=$1 ) ... #- Enjoy! :) P.S. - if You have CakePHP worked on other web server with some rewrite trick, let us know, please - if You speak English better then me, write some nice wiki article about it, please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
{n} ?
I was using the generateList() method to create an array I could use in a select drop down. Using the method without params would create an array of the ids, but when I tried to use the $keyPath and $valuePath params to create a key=value array that I could use, nothing was returned. The manual shows the path params format as just fieldName. Using this format returns nothing and neither does Model.fieldName. Finally after searching around I found an example in the API that says to use the path params in the format of {n}.Model.fieldName Changing to {n}.Model.fieldName fixed my problem, but I have no idea *why*. I searched around google, the wiki, the API, and manual, looking for more references to {n} and so far I've come up with nothing. So out of curiosity... what's with the {n} ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
why don't you do a new wiki page for that ? Because of my poor English - I hope there is someone in this group who will do it instead of me. If anyone is involved, I can co-operate with him, but I definitely cannot write some text and hope English-speaking people will not laugh on CakePHP programmers just because of me ;-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
All will become clear when we have different datasources in 2.0. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
You can search the wiki using the following in GoogleSearch Terms site:wiki.cakephp.orgReplace Search Terms above with whatever you are looking for. You can expand on your authentication system by using cake's built in ACL and ACO functionality.I have not completely figured it out yet, but I am currently working on it. I did get my user authentication system going though. Web services like SOAP can be granted or denied access through ACL and ACO.On 5/24/06, AD7six [EMAIL PROTECTED] wrote:Hi Peter,A gentle hint: search before asking.I guess I will have to get used to the required 1-1-1-1 mapping between controller, model, view and database table.That's not really true, the bit relavent to what you are asking is thatyou can have any number (including 0) of Models used by a controller;You can also create Models which don´t use a database and use other sources.This tool is pretty useful, although the wiki results are still broken:http://www.cakephp.org/searchYou´ll probably find that no matter what circumstance you can think of, by searching you will find it is either already included in Cake,is planned for, or is expandable to include your requirements in ascalable not-a-hack kind of way. The IRC is a good place to pick uphints if you can´t find an answer pretty quicky to concept type questions.Cheers,AD7six --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Global variables?
For a while AD7six provided the following. I'm not sure its up-to-date, it's my version I can't find the original anymore. The idea is to put your menu in a component so you load it only where its needed. Personally I have a dynamic menu and I build it in the model but I can't say if its the best approach. olivvv ### in your controller: var $components = array('Menu'); var $beforeFilter = array('init'); function init() { // Create menu component $this-Menu-controller = $this; $this-Menu-init($this-name); } ### the menu.php component ?php class MenuComponent extends Object { var $controller = true; var $MenuItems = array ( array ('home','/') , array ('members','/members/'), array ('experiments','/experiments/'), array ('CV','/cv/', array ( array('profile','/cv/#profile'), array('skill summary','/cv/#skills'), array('educati?n','/cv/#education'), array('experience','/cv/#experience'), array('interests','/cv/#interests') ) ), array ('FAQs','/faqs/', array ( array('security','/faqs/security'), array('privacy','/faqs/privacy') ) ), array ('contact','/contact/') ); function init () { $this-controller-set('MenuItems',$this-MenuItems); } } ? felle42 wrote: Thanks 100rk. setting the variables in bootstrap.php global did it for me! But why do I have to do this? isn´t the file(bootstrap.php) included by a php-include or -require? I need the global varibals for implementing submenues. I define them as an array an the controller selects the right one. is there a better way of doing this? greets felle42 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Global variables?
I can't find the original anymore. I saw it also and I also cannot find it :) When I'm in need for such as global configuration options, I'm using my 'Config' component, which API simply follows SessionComponent API. NOTE FOR ALL: it is licensed under one term: If You will use it, check if there is a page about it on cake wiki - if it doesn't exist yet and You're able describe what is important in correct English, make page about it on wiki and maintain it in future. app/controllers/components/config.php: ?php class ConfigComponent extends Object { function __construct() { parent::__construct(); $config = Configure::getInstance(); $vars = get_object_vars($config); if (!array_key_exists('custom', $vars) || !is_array($config-custom)) { $config-custom = array(); } } function write($name, $value) { $config = Configure::getInstance(); $config-custom[$name] = $value; } function read($name = null) { if (!is_null($name)) { if (ConfigComponent::check($name)) { $config = Configure::getInstance(); return $config-custom[$name]; } else { return null; } } else { $config = Configure::getInstance(); return $config-custom; } } function del($name) { if (ConfigComponent::check($name)) { $config = Configure::getInstance(); $unset($config-custom[$name]); } } function delete($name) { ConfigComponent::delete($name); } function check($name) { $config = Configure::getInstance(); return isset($config-custom[$name]); } } ? Usage in controller: var $uses = array('Config', ...); and then $this-set('menuArray', $this-Config-read('menuArray')); OR anywhere outside of this controller (if dispatcher is processid it's method) - in view, element, even in model: $menu = ConfigComponent::read('menuArray'); So in this particular case I will have to put in bootstrap.php code: $_conf = Configure::getInstance(); $_conf-custom = array('xyz' = 123); unset($_conf); and then access it as is described above. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Looking for examples
Hey I just checked again, the wiki search page seems to be behaving a little better. Some results relavent to this thread http://www.cakephp.org/search/index/mvc http://www.cakephp.org/search/index/authentication http://www.cakephp.org/search/index/webservices http://www.cakephp.org/search/index/SOAP Cheers, AD7six --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
I would also be interested in desmistifying it. I´m using it too in my current project and it works fine, but I have no idea what it is all about :)- Marcelo.On 5/24/06, gwoo [EMAIL PROTECTED] wrote:All will become clear when we have different datasources in 2.0. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
Hi Modfather, If your question was more how can to define your own helpers rather than how can I create a link, it seems to me that you were on the right track. I copied your code from this post to make absolutely certain before replying - I can't duplicate the error (not that that means much) with a clean install. Can you explain a little more how you arrived at your error, what version of cake are your running, and what other changes if any have you made? If there's any code to post, save it here to avoid cluttering the group messages. http://www.cakephp.org/pastes/add Cheers, AD7six --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
{n} represents a numeric key in an array structure. If you look at DataSource::getFieldValue( ) (which is the method underlying generateList( )), you can see in a little more detail how it works. This method is used to extract a cross-section of data from an array, and will, as gwoo said, become more important when Cake develops more DataSource abstractions. The idea is that if data from different sources (i.e. a database vs. the results of an XML-RPC query) can be structured in a similar way, it is possible to extract data necessary to associate different data from disparate sources. For example, imagine having a database table with a field that contained unique ID's of items in an Atom feed. You could define where to find the keys in the table, and where to find the keys in the Atom data structure, and Cake could automatically create relationships between the data, and return it all as a cohesive unit. Hope that answers everyones' questions. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Circularity with beforeFilter calling redirect
Simple fix: class AppController extends Controller { function beforeFilter() { if(!$this-isLoggedIn() $this-action != 'login') { $this-redirect('/user/login'); } } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Need Cake developer(s) to join project
Hello, I'm working on a fairly large project using Cake as the foundation, and I need to hire/partner with 1 or 2 other PHP/MySQL savvy developers to help out with various aspects of the system. Since much of the system is being built using Cake, ideally I'd be able to work with people who are already familiar with the framework. This would be a paid engagement that would begin almost immediately, with the potential for a long term relationship. If you're interested, please email me at the address on my profile, and we can discuss the details. If I've posted this in an inappropriate place, please accept my apologies, and please point me in the right direction if you can. Best regards, Stephen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Need Cake developer(s) to join project
[EMAIL PROTECTED]-- /*** @author Larry E. Masters* @var string $userName* @param string $realName* @returns string aka PhpNut * @accesspublic*/On 5/24/06, stephenrs [EMAIL PROTECTED] wrote: Hello,I'm working on a fairly large project using Cake as the foundation, andI need to hire/partner with 1 or 2 other PHP/MySQL savvy developersto help out with various aspects of the system. Since much of the system is being built using Cake, ideally I'd be able to work withpeople who are already familiar with the framework. This would be apaidengagement that would begin almost immediately, with the potential for a long term relationship.If you're interested, please email me at the address on my profile, andwe can discuss the details.If I've posted this in an inappropriate place, please accept myapologies, and please point me in the right direction if you can. Best regards,Stephen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
understanding models
hi. I've this: // app/models/post.php class Post extends AppModel { var $name = 'Post'; var $belongsTo = 'State, Region, Province, City, User, Contract, Tipology, Category'; } and // app/models/region.php class Region extends AppModel { var $name = 'Region'; var $belongsTo = 'State'; } when calling $this-Region-findAll(); from controller I have the expected results: Array ( [0] = Array ( [Region] = Array ( [id] = ABR [name] = ABRUZZO [code] = 13 [state_id] = IT [superficie] = 10.794 km² [abitanti] = 1.300.000 [densita] = 120 ab./km² [city_id] = 49 ) [State] = Array ( [id] = IT [name] = ITALIA ) ) and so on, Region is linked to State model. I only use belongsTo for my model, but now I need extra functionality. I need to have the number of posts for each region, posts table contains a region_id field. is that possible? any hints how to configure relationships between these tables? thanks. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
I'm no native english speaker and I think your english is easy to understand ;) If your wiki page is useful and being used, people will correct it especially if you mention that they should feel free to correct mistakes in your english. That is what makes the wiki a cool tool. Anyway it was just a suggestion. 100rk wrote: why don't you do a new wiki page for that ? Because of my poor English - I hope there is someone in this group who will do it instead of me. If anyone is involved, I can co-operate with him, but I definitely cannot write some text and hope English-speaking people will not laugh on CakePHP programmers just because of me ;-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: understanding models
Region hasMany Posts --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: debug only in certain areas
You could try adding define('DEBUG','2'); to the method. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Simple HABTM Question
AD7six, Thanks for this post! I ran into the same problem as brandags. I have a question though. Yes this does work, but why does it work? I thought the arrow (-) referenced a member of the class like a method or member. Is that right? If so how did Service become a member of Contractor? Can you give a brief explanation? Thanks, Dee --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
Cool. Its of no use for me (I have only Apache) but the more the better in the wiki. 100rk wrote: Thanks, Olivier. Problem is: it allways takes a long time to me (explain something in English) if I cannot see person I'm talking with ;-), but You're surely right, so I will make some wiki page about it. I will let You know here. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
AD7six, firstly thanks for your input and contributions in the wiki and forum. I am using PHP Version 4.4.2 and cake version 1.0.1.2708. I looked at your cssmenu code in the wiki as i need to generate a menu from a database - i could not get your examples to work - so i simplified the code for testing, still not working. I put static text in the element and it appeared in the layout, but everytime i tried to access a method of a custom helper class i get a non-object error. Somewhere along the line the helper class is not being recognised/registered or instantiated. I will try a clean install of cake and see how i go. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Very Frustrated - No help for newbies !!!!
Hi Everyone, Thanks for the responses and sorry for delay in getting back. I certainly didn't mean to rock the boat and apologies if I came over as being a bit heavy... Larry, I certainly was NOT the person who was abusive in the IRC. I will get back to things in the next day or so and work more closely through the suggestions as I have time. And I will certainly document my findings and contribute them if they are of any help to future newbies... I'll be back with my findings. regards, Dave Porter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
Just reinstalled cake added the same pages as before but still get the Fatal error: Call to a member function on a non-object in /cake/app/views/elements/test.thtml on line 1 - very,very frustrating - i think these sort of php/framework errors are the reason i left php for ruby on rails in the first place - anyway thanks for the replies. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom SQL and Weird Arrays
Guys;I'm executing this custom SQL:$sql = select c_product_id, count(*) as count from c_combocontents, c_combos where c_combos.id = c_combo_id and c_optioncontent_id in (1,2,3,4,5) and c_combos.current =1 group by c_product_id,c_combo_id;$oc = $this-modelname-query($sql);The results i'm getting produce an array like this in dev (xp,mysql) Array([0] = Array([c_combos] = Array([c_product_id] = 477)[#sql_dc8_0] = Array ([count] = 1)))The problem is that the #sql_dc8_0 bit changes all the time, in my live linux env the key seems to be a zero all the time. Does anyone have any ideas on this one? I have dug though the low level code but cant actually find where it creates the array. Cheers,Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Custom SQL and Weird Arrays
I actually had this happen once, and I want to say it was actually related to the database's character encoding. Try converting it to a findAll query and see what happens. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Custom SQL and Weird Arrays
Hi Nate;I'm pretty sure a findAll wont work as that is sime weird-ass SQL from a cake perspective.I'll keep on playing.MattOn 5/25/06, nate [EMAIL PROTECTED] wrote: I actually had this happen once, and I want to say it was actuallyrelated to the database's character encoding.Try converting it to afindAll query and see what happens. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Acccessing Helpers from Layout
Just tried further debugging; 1. moved custom helper out of element and straight into layout result = fatal error - as above. 2. added the custom helper to the core html helper file - result it works in the layout, ie $html-makeEdit(). 3. There must be a problem with the appcontroller file not registering custom helpers - i also could not access the $helpers array variable in the layout file. I also tries various combinations of case on variables and file names to no avail. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
AppController not registering Helpers
I wanted to add a customer helper to my layout file. I would get the Fatal error: Call to a member function on a non-object in etc, i registered the helper in the app_controller file via $helpers = array('link'); also tried $helpers = array('Link');- still got fatal error.I then added the customer helper to core controller.php(line 86) file, specifically var $helpers = array('Html','Link'); - now i can access the custom helper in the layout - so i can only conclude that helpers are not being registered/recognised in the AppController file. I am using PHP Version 4.4.2 and cake version 1.0.1.2708. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
Can you post all your code using the cakebin ? 2 things : -Don't touch the core else nobody can help you.(Apart for playing/understanding it, but dev should be made with a vanillia version) -Its probably not a bug, i've also some code with a custom helper in my layout. olivvv modfather wrote: I wanted to add a customer helper to my layout file. I would get the Fatal error: Call to a member function on a non-object in etc, i registered the helper in the app_controller file via $helpers = array('link'); also tried $helpers = array('Link');- still got fatal error.I then added the customer helper to core controller.php(line 86) file, specifically var $helpers = array('Html','Link'); - now i can access the custom helper in the layout - so i can only conclude that helpers are not being registered/recognised in the AppController file. I am using PHP Version 4.4.2 and cake version 1.0.1.2708. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Nice URLs and webservers other then apache
so far I find it well written :-) 100rk wrote: http://wiki.cakephp.org/tutorials:url_rewrite_without_apache is the answer, just give me a day, people. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
Are You sure You did call parent methods in methods which are redefining methods of parent class? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
It doesn't show IF Your AppController is in proper directory with proper filename --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Global variables?
Little enhancement for this component for those who are using multiple places for M/V/C files: function getModelPaths() { $config = Configure::getInstance(); return $config-modelPaths; } function getViewPaths() { $config = Configure::getInstance(); return $config-viewPaths; } function getControllerPaths() { $config = Configure::getInstance(); return $config-controllerPaths; } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
sorry - app_controller.php is in app/controllers/app_controller.php 100rk are you saying i have to call a constuctor in a custom helper class, which in turn call the parent constuctor? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
just in case there was confusion between the name link i changed the helper name to RedHelper(red.php), changed the name of the function from makeEdit() to bye(), still the same result, no recognition when added to app_controller.php helpers array - when added to core controller.php, it works. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
try ?php class LinkHelper extends Helper //tried also without extends { function makeEdit() { return "linkhelper"; } } ? modfather wrote: just in case there was confusion between the name "link" i changed the helper name to RedHelper(red.php), changed the name of the function from makeEdit() to bye(), still the same result, no recognition when added to app_controller.php helpers array - when added to core controller.php, it works. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
Thank you for your explanation. This idea seems very similar to ASP.NET's datasource concept in which data from any supported source (such as XML or most DBMS as mentioned) are treated exactly the same. This should become yet another useful resource for cake. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
look I have the head helper made by rossoft: That's functionning, nothing more, no core change. app_controller.php class AppController extends Controller { var $helpers = array('Javascript', 'Head'); } layout/default.thtml : !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html head title?php echo $title_for_layout;?/title link rel=shortcut icon href=favicon.ico type=image/x-icon ?php echo $html-charset('UTF-8');? ?php echo $html-css('default');? ?php if (isset($head)) echo $head-print_registered();? /head body ?php echo $content_for_layout;? /body /html modfather wrote: Olivier, thanks for your persistance, but you could have an empty function with nothing returning, you still have the same result, the fact is if it works by adding the helper to helper array in the controller.php file, it should work by adding the helper to the helper array in the appcontroller, but it doesn't, somehwere along the line the class is not being registered - it might have something to do with the flow of logic of the chain of execution of classes. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
Thats what i mean i have tried various methods(altering the controller was to see if there was somethingh wrong with my helper class, but there is not) to get this to work and examples but it is not working, thats why it is frustrating, i will try the rossoft head helper and see if it works - at the momment i cannot see what i am doing wrong. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
For PHPNut :: Mssql driver issue getting identity value back
I am running PHP5 on win2003, with apache2, sql server 2000. Cake appears to be having an issue getting the identity value back from sql server. When I attempt to add a new record to a table I get this error: === Notice: Undefined index: insertID in C:\Program Files\Apache Group\Apache2\htdocs\cake\libs\model\dbo\dbo_mssql.php on line 502 == I modded dbo_mssql.php like this: $id = $this-fetchAll('SELECT SCOPE_IDENTITY() AS insertID', false); pr ($id); return $id[0]['insertID']; and this is this $id array that comes back back from sql server: == Array ( [0] = Array ( [0] = Array ( [insertID] = 5 ) ) ) == BUT, the cake dbo code is not looking far enough into the array: return $id[0]['insertID']; Is it me or Sql server or something else?? thanks, Pat. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: AppController not registering Helpers
app_controller.php should be in the /app folder, not /app/controllers --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
Yeah, it is pretty similar. The only difference is that ASP.NET *blows*. ;-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: {n} ?
Ahah, after just finishing a semester on ASP.NET I feel confident in completely agreeing with you. CakePHP is one more reason to not use ASP.NET :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: For PHPNut :: Mssql driver issue getting identity value back
Fixed in SVN. Next time submit a ticket at trac.cakephp.org. Thanks. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Offtopic? Exporting functions from namespaces
(Off-topic, but I didn't know where to post this, so...) I like functional programming, but I also like classes because they sort of auto-organize the scripts. Here's a piece of code I've come up to join them. Is there any reason I shouldn't use this techique (reliability, performance, limitations)? Is there an easier way of creating new functions on the fly or mapping functions to static methods? Basicaly, this code takes a list of class methods and dynamically (using eval()) creates functions that call those methods. This way you can keep your helper functions in classes (I use quite a few), but still be able to call them as functions to keep the code concise. It also creates a unified class constructor method in PHP4 -- Class::_init(). The other reason I'm playing with this is because I want to tackle the issue of code generation. I've done some testing and it seems that a large portion of script processing time is taken by include()/require() calls. I want to be able to compile a whole application into a single PHP file, and I need to organize my code to allow for that. ? class Base { /** Methods specified here will be exported into global namespace as functions. */ var $_export = array(); function Base() { Base_Lang::export(get_class($this), $this-_export); Base_Lang::call($this, '_init'); } /** This function is executed at object's creation. * To be overrided in descending classes. */ function _init () {} } new Base; class Base_Lang extends Base { var $_export = array('export', 'call'); /** Exports class methods (specified with $funcs) into * global namespace as functions. */ function export ($class, $funcs=array()) { $php = ''; foreach ($funcs as $func=$alias) { if ($func*1==$func) $func = $alias; if (!function_exists($alias)) { $php .= function $func(){ \$args=func_get_args(); return Base_Lang::call('$class','$func',\$args); }\n; } } eval($php); } /** * An alias for call_user_func_array() with simplified syntax */ function call ($obj, $fn=false, $params=-1) { if (is_string($fn)) { $C = array($obj, $fn); $P = is_array($params)? $params: array(); } else { $C = $obj; $P = is_array($fn)? $fn: array(); } return call_user_func_array($C, $P); } } new Base_Lang; class MyTest extends Base { var $_export = array('foo', 'bar', 'baz'='woot'); function foo(){ return 'Ea'; } function bar(){ return 'sy'; } function baz(){ return '!'; } } new MyTest; // outputs 'Easy!' print foo().bar().woot(); ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: For PHPNut :: Mssql driver issue getting identity value back
many thanks, will do. Does this mean I'm the only one using phpcake on windows/Sql server ?? Pat. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to avoid the 'EDIT' action 'ADD' a new record when you changed PK.
But,my aim is to allow user to change the PK value ,and also can avoid the save method to create a new PK value while still keep the old record, so I use the model-db-update method. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---