Or if you're feeling brave, you could edit the templates in ..cake/
console so that your controllers, models and views are created the way
_you_ want them.

On 15 June, 18:21, calvin <cal...@rottenrecords.com> wrote:
> Yea, I think you'll be hard pressed to find a justification for
> merging all the views together. It could become a maintenance
> nightmare. Besides, cake bake makes generating views quick and
> painless. It literally takes only 2-3 seconds to generate all the
> views for a single controller/model.
>
> If you're going to spend time working on views and want to eliminate
> duplicate code, I would recommend breaking down repeated view code
> into elements. For example, most of my edit and add views share a form
> element. The element is usually named something like form.user or
> form.rates (allows adding multiple rates at once) and contains
> conditional logic for handling the differences between edit and add
> actions.
>
> Likewise, another good idea (IMO) I've found is to eliminate the
> "actions" list that cake bake generates for each view. These actions
> are hardcoded links that can be a pain to update. Some people just
> rebake every time they make changes to model associations to update
> the actions list, but this isn't really an option if you have
> customized views that have been modified after baking. So instead of
> that, I just have an element called "actions" that I place inside of
> each view, which renders the actions that I specify inside of the
> controller like so:
>
> var $actions = array(
>         array(
>                 'label' => 'Explore {%N}',
>                 'url' => array('action' => 'explore'),
>                 'pass' => true,
>                 'on' => array('view', 'edit')
>         ),
>         array(
>                 'label' => 'View {%N}',
>                 'url' => array('action' => 'view'),
>                 'pass' => true,
>                 'on' => array('explore', 'edit')
>         ),
>         array(
>                 'label' => 'Edit {%N}',
>                 'url' => array('action' => 'edit'),
>                 'pass' => true,
>                 'on' => array('view')
>         ),
>         array(
>                 'label' => 'Delete {%N}',
>                 'url' => array('action' => 'delete'),
>                 'pass' => true,
>                 'on' => array('view', 'edit')
>         ),
>         array(
>                 'label' => 'List {%Ns}',
>                 'url' => array('action' => 'index')
>         ),
>         array(
>                 'label' => 'List {%Ns}',
>                 'url' => array('controller' => 'media_files', 'action' => 
> 'index')
>         ),
>         array(
>                 'label' => 'New {%Ns}',
>                 'url' => array('controller' => 'media_files', 'action' => 
> 'add')
>         )
> );
>
> You can probably also turn "associated data" tables into elements or
> create helpers that help you generate AJAX tables or something. All of
> this will help you simply your views and reduce repetitive code.
>
> On Jun 15, 8:44 am, leo <ponton....@gmail.com> wrote:
>
> > Yes, you can do that by having conditional code in the view and
> > setting the template:
> > $this->render('crudView');
>
> > and a mode in a view variable:
> > $this->set('mode','edit');
>
> > In general, you be better off following the accepted way, though, as
> > things can get terribly comfusing and complicated if you don't. You're
> > not saving paper or electricity by combining into one view. Keep it
> > simple and keep it clear.
>
> > On 15 June, 09:35, Mario Simaremare <mariosimarem...@gmail.com> wrote:
>
> > > dear all,
>
> > > i am very new with php and the cake. i used to play with java
> > > actually.
> > > i would ask you, if there is a way in the cake to create a single view
> > > file to view, add, and edit then reuse them.
> > > i mean to use the same view with different models. the views
> > > automatically detects the table columns and it's header then fill the
> > > cell with the thrown models data?
>
> > > thank you,
>
> > > regards,

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to