Re: Refactoring Views

2006-10-23 Thread Matt Adams

[EMAIL PROTECTED] wrote:

 Ditto I would love to see that framework, Matt, even if it's not all
 packaged up and ready for prime time.

I will do my utmost to release it when I have time.  I've been crazy 
busy lately and haven't had time to even think about it.

I will, of course, have to get corporate approval before I do because 
I'm not bankrolling it's production.  The framework isn't actually our 
product though, we just use it to build apps with it.


Cheers,

Matt
-- 
BASIC: A programming language.  Related to certain social diseases
in that those who have it will not admit it in polite company.

--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-22 Thread Sonic Baker
Hi guys,Thank you your responses and code samples. Some interesting things to think about. Your input has been very much appreciated.Cheers,Sonic

--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-21 Thread [EMAIL PROTECTED]

Ditto I would love to see that framework, Matt, even if it's not all
packaged up and ready for prime time.

I've been thinking since starting with Cake that more extensive and
versatile code generation would advance Cake from merely wonderful to
absolutely earthshaking, Holy Grail kind of material.


--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-20 Thread Sonic Baker
Hi Matt,Thank you for your reply.I was just using the forms generated form Bake as an example to illustrate the types of duplication I mean.That meta-framework of yours sounds wonderful. Is it hard on resources?
If you weren't using it, how would you answer my questions above?Cheers,Sonic

--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-20 Thread Matt Adams

Sonic Baker wrote:

 I was just using the forms generated form Bake as an example to 
 illustrate the types of duplication I mean.
 
 That meta-framework of yours sounds wonderful. Is it hard on resources?

Not particularly.  Running in production mode it takes about 1 second to 
render each view.

I intend to write a program that will go through all of the permutations 
in my application and build up a data structure that can be loaded and 
accessed several by a Cake app (probably via shared memory or some other 
similar construct).  I haven't crunched the numbers yet but I imagine 
that doing this will give the app around a 50% boost in efficiency.

 If you weren't using it, how would you answer my questions above?

You're right, I didn't quite answer your question.  Sorry.

Yes, I use elements (and lots of helpers) that have all of the necessary 
logic built in or can provide that sort of form logic.  You can almost 
pretend that I don't have a meta-framework.  All it really does is 
provide the data or configuration information necessary to build the 
various pieces of the view (actually it does a lot more than that but as 
far as the view is concerned it only provides a data structure so Cake 
can figure out where to put stuff).


Cheers,

Matt
-- 
BASIC: A programming language.  Related to certain social diseases
in that those who have it will not admit it in polite company.

--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-20 Thread Christian Winther

 To be brief, what I've done is create a meta-framework that works 
 hand-in-hand with Cake (using Cake itself and a small number of external 
 scripts and processes) that is able to generate all of my views for me 
 using a series of reusable elements and helpers.
 This meta-framework knows when to expose information on a given screen 
 using what I call applets (nothing to do with Java).  Applets are a 
 collection of fields in a certain state and having certain properties 
 (or rather a collection of fields spanning multiple models associated 
 with an instance of an applet that is assigned to a particular view).

Is this a public meta-framework or a private closed source ?

/Christian


--~--~-~--~~~---~--~~
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: Refactoring Views

2006-10-20 Thread Grant Cox

I'd be interested in seeing it too.

Personally I make a _addedit($id) action in my controller, and a
_addedit.thtml element (in with the normal view files).  These have the
common parts of add and edit in them.  I'm not sure if this will stay
this way once I start serious work on the application UI, but we are
still adding features (including new models, and changing model fields)
at this stage, and this does make it faster to keep things updated.

ie: UsersController:

function add() {
$this-_addedit();
}

function edit($id) {
$this-_addedit($id);
}

function _addedit($id=null)
{
if ( !empty($this-params['form']['cancel']) ){
$this-Session-setFlash('The User was not saved');
$this-redirect('/users/index');
return false;
}

if(empty($this-data)) {
if ( empty($id) ){
// give default values
} else {
// add the associated models for the edit view
$this-_read_associations( $id );
$this-data = $this-User-read(null, $id);
}

$this-render();
} else {
$this-cleanUpFields();

if($this-User-save($this-data)) {
$this-Session-setFlash('The User has been 
saved');
$this-redirect('/users/index');
} else {
$this-Session-setFlash('Please correct errors 
below.');

if ( !empty($id) ){
$this-_read_associations( $id );
}
}
}
}


Both views/users/add.thtml and views/users/edit.thtml have

echo $this-renderElement('../users/_addedit');

in them, which renders the views/users/_addedit.thtml element - this is
what has all the actual form values.  It only has the common form
elements, as you often want some differences between the add and edit
forms.

I also have a views/users/_associated.thtml , which displays the
associated models (like what you normally see on the view template).
I like these associations to also be shown when editing, so again it's
a bit simpler to keep in a separate element.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---