I have an idea I want to to share with You.

I made some fancy element called list (http://bin.cakephp.org/view/
127456247). The implementation is not that important, it's just
foreach You always do when listing stuff from db (putting them into tr/
td, marking odd tr's, adding some links at the end and so).

Now, as You could see in the code - there are Two functions defined to
make code below more clear. But what concerns me is that I'm not
protected from possible function names conflicts.

Since I cannot add my function into a namespace like MyApp\Views
\Elements\List (because I cannot be sure if my php version is 5.3) so
i thougt about changing it into a helper. It seemed like a good idea
until I saw (in my mind) this whole html in php strings - that sucks a
lot.

I thought about new feature: Helper elements - elements that are owned
by Helpers.

Check this out.

I make helper in a new way:
/views/helpers/list/list.php
class ListHelper extends Helper() {
  function doSth(){
     // some code, preparing structures
     $this->renderHelperElement("my_element");
  }

   function doSomethingUsefull($param) {
     return array("foo"=>$param);
   }
}

and then I can define
/views/helpers/list/my_element.ctp
// bunch of html
<?php $stuff = $this->doSomethingUsefull("bar"); ?>
<?php foreach($stuff as $k => $v): ?>
//
<?php endforeach; ?>

Good points are that we can make better separation between data
manipulation and representation.
Problem could be ciclick dependency between Helper and his elements.

Is that description clear for You? What do You think about it cake-
friends?

Thanks for Your time.
Grzegorz

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