Re: strange request: store view templates in one location
Thanks for all the feedback, it was an odd request, but I learned a lot from the replies, I have to admit. In the end, I am going to leave it alone, and he can either live with it, pay more, or go away. I have enough work that his isn't critical, which hasn't always been the case. I'm learning to say no, I suppose. Thanks again for all the helpful solutions, I do like the symlink idea myself and will keep that in my files for future reference. brian --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
I get the feeling this is the type of client who might call you up in 6 months complaining about how many templates there are and request that you organize them into sub-directories. It is probably worth your time to try and convince this guy to defer to your expertise and trust you that the default way of organizing template files is the best way to do it from a long term project management perspective. As for sharing forms ... why do you need to hide the id field in the add.ctp file? You can just use the exact same form for both operations, with the id field being blank in the add version of the form. In the controller's add() function, you can set the value of the id field to null before saving just to make sure that a new record gets created. -Aran On Nov 20, 12:23 pm, Predominant <[EMAIL PROTECTED]> wrote: > I do something similar, but I use element variables to indicate > whether or not the ID field should be used: > > add.ctp / edit.ctp --- Just change the includeId to true / false as > required, leaving it out defaults to false. > element('users/form', array('includeId' => true)); ? > > > > views/elements/users/form.ctp > echo $form->create('User'); > if (isset($includeId) && $includeId) { > echo $form->input('id');} > > echo $form->input('username'); > echo $form->input('password'); > echo $form->end('save'); > ?> > > Thus, your form inclusion code on the add / edit pages is minimalised. > You can extend this to include other optional items. > > Cheers, > Graham > > On Nov 21, 7:16 am, validkeys <[EMAIL PROTECTED]> wrote: > > > Another bit of advice that I could give you is this. > > > What I am guessing he is annoyed with is if he makes a change to the > > form on the add view, he has to then laboriously navigate to the edit > > view and make the same change. What I have been doing is this. > > > In the elements folder, I create a folder for each controller > > (users). > > > Lets say my add form is: > > > > echo $form->create('User'); > > echo $form->input('username'); > > echo $form->input('password'); > > echo $form->end('Submit') > > ?> > > > and my edit form is: > > > > echo $form->create('User'); > > echo $form->input('id') > > echo $form->input('username'); > > echo $form->input('password'); > > echo $form->end('Submit') > > ?> > > > To reduce coupling, I place the common elements in elements/users/ > > form.ctp and then just include it in the template like this: > > > > echo $form->create('User'); > > echo $this->element('users/form'); > > echo $form->end('Submit'); > > ?> > > > > echo $form->create('User'); > > echo $form->input('id'); > > echo $this->element('users/form'); > > echo $form->end('Submit'); > > ?> > > > This looks like more work when there are only 2 fields. But it's just > > an example. > > On Nov 20, 10:10 am, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > I have an strange client that just can't get past the fact that view > > > templates are, in his words "scattered across so many locations". Is > > > there a way to set up a single folder and a name convention then tell > > > the view where to find the files? For examples, all user templates > > > would be something like user_add.ctp, user_edit.ctp, etc. > > > > Then he could edit as necessary. > > > > I try to convince him to keep his changes to the layout but he want to > > > tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
Graham's way is way better. How did I not think of this! Thanks Graham! On Nov 20, 3:23 pm, Predominant <[EMAIL PROTECTED]> wrote: > I do something similar, but I use element variables to indicate > whether or not the ID field should be used: > > add.ctp / edit.ctp --- Just change the includeId to true / false as > required, leaving it out defaults to false. > element('users/form', array('includeId' => true)); ? > > > > views/elements/users/form.ctp > echo $form->create('User'); > if (isset($includeId) && $includeId) { > echo $form->input('id');} > > echo $form->input('username'); > echo $form->input('password'); > echo $form->end('save'); > ?> > > Thus, your form inclusion code on the add / edit pages is minimalised. > You can extend this to include other optional items. > > Cheers, > Graham > > On Nov 21, 7:16 am, validkeys <[EMAIL PROTECTED]> wrote: > > > Another bit of advice that I could give you is this. > > > What I am guessing he is annoyed with is if he makes a change to the > > form on the add view, he has to then laboriously navigate to the edit > > view and make the same change. What I have been doing is this. > > > In the elements folder, I create a folder for each controller > > (users). > > > Lets say my add form is: > > > > echo $form->create('User'); > > echo $form->input('username'); > > echo $form->input('password'); > > echo $form->end('Submit') > > ?> > > > and my edit form is: > > > > echo $form->create('User'); > > echo $form->input('id') > > echo $form->input('username'); > > echo $form->input('password'); > > echo $form->end('Submit') > > ?> > > > To reduce coupling, I place the common elements in elements/users/ > > form.ctp and then just include it in the template like this: > > > > echo $form->create('User'); > > echo $this->element('users/form'); > > echo $form->end('Submit'); > > ?> > > > > echo $form->create('User'); > > echo $form->input('id'); > > echo $this->element('users/form'); > > echo $form->end('Submit'); > > ?> > > > This looks like more work when there are only 2 fields. But it's just > > an example. > > On Nov 20, 10:10 am, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > I have an strange client that just can't get past the fact that view > > > templates are, in his words "scattered across so many locations". Is > > > there a way to set up a single folder and a name convention then tell > > > the view where to find the files? For examples, all user templates > > > would be something like user_add.ctp, user_edit.ctp, etc. > > > > Then he could edit as necessary. > > > > I try to convince him to keep his changes to the layout but he want to > > > tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
I do something similar, but I use element variables to indicate whether or not the ID field should be used: add.ctp / edit.ctp --- Just change the includeId to true / false as required, leaving it out defaults to false. element('users/form', array('includeId' => true)); ? > views/elements/users/form.ctp create('User'); if (isset($includeId) && $includeId) { echo $form->input('id'); } echo $form->input('username'); echo $form->input('password'); echo $form->end('save'); ?> Thus, your form inclusion code on the add / edit pages is minimalised. You can extend this to include other optional items. Cheers, Graham On Nov 21, 7:16 am, validkeys <[EMAIL PROTECTED]> wrote: > Another bit of advice that I could give you is this. > > What I am guessing he is annoyed with is if he makes a change to the > form on the add view, he has to then laboriously navigate to the edit > view and make the same change. What I have been doing is this. > > In the elements folder, I create a folder for each controller > (users). > > Lets say my add form is: > > echo $form->create('User'); > echo $form->input('username'); > echo $form->input('password'); > echo $form->end('Submit') > ?> > > and my edit form is: > > echo $form->create('User'); > echo $form->input('id') > echo $form->input('username'); > echo $form->input('password'); > echo $form->end('Submit') > ?> > > To reduce coupling, I place the common elements in elements/users/ > form.ctp and then just include it in the template like this: > > echo $form->create('User'); > echo $this->element('users/form'); > echo $form->end('Submit'); > ?> > > echo $form->create('User'); > echo $form->input('id'); > echo $this->element('users/form'); > echo $form->end('Submit'); > ?> > > This looks like more work when there are only 2 fields. But it's just > an example. > On Nov 20, 10:10 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > I have an strange client that just can't get past the fact that view > > templates are, in his words "scattered across so many locations". Is > > there a way to set up a single folder and a name convention then tell > > the view where to find the files? For examples, all user templates > > would be something like user_add.ctp, user_edit.ctp, etc. > > > Then he could edit as necessary. > > > I try to convince him to keep his changes to the layout but he want to > > tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
Another bit of advice that I could give you is this. What I am guessing he is annoyed with is if he makes a change to the form on the add view, he has to then laboriously navigate to the edit view and make the same change. What I have been doing is this. In the elements folder, I create a folder for each controller (users). Lets say my add form is: create('User'); echo $form->input('username'); echo $form->input('password'); echo $form->end('Submit') ?> and my edit form is: create('User'); echo $form->input('id') echo $form->input('username'); echo $form->input('password'); echo $form->end('Submit') ?> To reduce coupling, I place the common elements in elements/users/ form.ctp and then just include it in the template like this: create('User'); echo $this->element('users/form'); echo $form->end('Submit'); ?> create('User'); echo $form->input('id'); echo $this->element('users/form'); echo $form->end('Submit'); ?> This looks like more work when there are only 2 fields. But it's just an example. On Nov 20, 10:10 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have an strange client that just can't get past the fact that view > templates are, in his words "scattered across so many locations". Is > there a way to set up a single folder and a name convention then tell > the view where to find the files? For examples, all user templates > would be something like user_add.ctp, user_edit.ctp, etc. > > Then he could edit as necessary. > > I try to convince him to keep his changes to the layout but he want to > tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
seconded On Nov 20, 1:49 pm, AD7six <[EMAIL PROTECTED]> wrote: > On Nov 20, 6:29 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > The difference, to the client, is when you have 100+ views in 10 or 15 > > folders. > > > I prefaced this whole thing with "strange request", so I'm just trying > > to keep a client happy if the solution is not unbearable, that's all. > > What I find hard to understand, and I'm not questioning you, is how > having a single folder with 100 files in it is easier to understand/ > find things than a folder containing 10 - 15 sub sets of files. > > I'd also go the route of creating app/plonker_views and writing a > script to symlink everything into it. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
On Nov 20, 6:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > The difference, to the client, is when you have 100+ views in 10 or 15 > folders. > > I prefaced this whole thing with "strange request", so I'm just trying > to keep a client happy if the solution is not unbearable, that's all. What I find hard to understand, and I'm not questioning you, is how having a single folder with 100 files in it is easier to understand/ find things than a folder containing 10 - 15 sub sets of files. I'd also go the route of creating app/plonker_views and writing a script to symlink everything into it. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
@grigri: Clever and elegant solution, good job. :-) @wisecounselor: Difficult clients are to be educated, charged more, or fired. Hehehe. --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
The difference, to the client, is when you have 100+ views in 10 or 15 folders. I prefaced this whole thing with "strange request", so I'm just trying to keep a client happy if the solution is not unbearable, that's all. On Nov 20, 9:49 am, AD7six <[EMAIL PROTECTED]> wrote: > On Nov 20, 4:10 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > I have an strange client that just can't get past the fact that view > > templates are, in his words "scattered across so many locations". Is > > there a way to set up a single folder and a name convention then tell > > the view where to find the files? For examples, all user templates > > would be something like user_add.ctp, user_edit.ctp, etc. > > What's the difference? > views/users/add.ctp > views/user_add.ctp --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
*On Thu, Nov 20, 2008 at 07:49:33AM -0800 AD7six <[EMAIL PROTECTED]> wrote: > What's the difference? > views/users/add.ctp > views/user_add.ctp I think the problem arises as more views are added: views/profiles/add.ctp views/profiles/edit.ctp views/users/add.ctp views/users/edit.ctp views/orders/add.ctp views/orders/view.ctp Too many folders to browse in and out of for an odd bird client. Instead he wants views/ profiles_add.ctp profiles_edit.ctp users_add.ctp users_edit.ctp orders_add.ctp orders_view.ctp If it were me, and assuming it's running on a *nix system, I'd create a new directory somewhere and call it templates, then symlink all the views into there. It would require maintenance such that anytime a new view is added you'd have to symlink it but, it would work. mkdir templates; ln -sv views/users/add.ctp templates/users_add.ctp Would produce: tmplates/user_add.ctp -> views/users/add.ctp -- Jon Molesa [EMAIL PROTECTED] if you're bored or curious http://rjmolesa.com --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
On Nov 20, 4:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have an strange client that just can't get past the fact that view > templates are, in his words "scattered across so many locations". Is > there a way to set up a single folder and a name convention then tell > the view where to find the files? For examples, all user templates > would be something like user_add.ctp, user_edit.ctp, etc. What's the difference? views/users/add.ctp views/user_add.ctp --~--~-~--~~~---~--~~ 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: strange request: store view templates in one location
Here's a proof-of-concept thingy: class AppController extends Controller { function render($action = null, $layout = null, $file = null) { if ($this->viewPath != 'errors') { $action = '../' . $this->viewPath.'_'.($action===null?$this->action: $action); //$this->log($action); //die($action); } return parent::render($action, $layout, $file); } } This will make, for example, the 'Users' controller's action 'view' use the template '/views/users_view.ctp'. It will affect ALL controllers and ALL actions. I doubt you'd want to go this far though - overriding every controller seems a bit heavy-handed. hth grigri On Nov 20, 3:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have an strange client that just can't get past the fact that view > templates are, in his words "scattered across so many locations". Is > there a way to set up a single folder and a name convention then tell > the view where to find the files? For examples, all user templates > would be something like user_add.ctp, user_edit.ctp, etc. > > Then he could edit as necessary. > > I try to convince him to keep his changes to the layout but he want to > tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
strange request: store view templates in one location
I have an strange client that just can't get past the fact that view templates are, in his words "scattered across so many locations". Is there a way to set up a single folder and a name convention then tell the view where to find the files? For examples, all user templates would be something like user_add.ctp, user_edit.ctp, etc. Then he could edit as necessary. I try to convince him to keep his changes to the layout but he want to tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---