Hi.
I'm traying to display in a view a string asociated to a field value.

<?php
  $i = 0;
  foreach ($datas as $data):
    $class = null;
    if ($i++ % 2 == 0) {
      $class = ' class="altrow"';
    }

   switch ($data['Model']['field'])
    {
    case 'A':
         $varp = __('String1',true);
         break;
    case 'B':
         $pasta = __('String2',true);
         break;
    case 'C':
         $pasta = __('String3',true);
         break;
    };

     .....
    <td> ..  echo $varp ..</td>

endforeach;

?>

I need to reuse this switch statement in other views. I create an
element with this code and store this file in the views/elements
folder.

<?php
  $i = 0;
  foreach ($datas as $data):
    $class = null;
    if ($i++ % 2 == 0) {
      $class = ' class="altrow"';
    }

   $this->renderElement('mycode');

     .....
    <td> ..  echo $varp ..</td>

endforeach;

?>
If I use renderElement doesn´t work because the code is a Swicht
estatement and render the element for each bucle cicle.
I tryed a include('mycode.ctp') by I don´t know how to reach this
folder.

How is the best way to do this?

Thanks.
Pau.

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