On Monday 01 Mar 2010 11:39:24 [email protected] wrote:
> Hi, i need to generate complex html in some viewHelpers.
> Now i am using heredoc notation but i am looking for a best solution.
> Some tips?
> 
> Here is an example of a viewHelper i am using:
> 
> <?php
> 
> class Zend_View_Helper_EditorPagineTesti extends Zend_View_Helper_Abstract
> {
> 
>       public function editorPagineTesti($elemento) {
> 
>               $id_elemento = $elemento->getIdForEditor();
> 
>               $textArea = $this->view->formTextarea('textarea_'.$id_elemento,
> $elemento->testo, array('style' => 'width: 910px;',
> 'class'=>'tinymce'));
> 
>               $html =  <<<HTML
>               <div style="display: none;" id="editor_$id_elemento">
>                       $textArea
>                       <button 
> onclick="salvaModifiche('$id_elemento');">Salva</button>
>                       <button 
onclick="annullaModifiche('$id_elemento');">Annulla</button>
>               </div>
> HTML;
>               return $html;
>       }
> }

I'd let de view helper do the logic, a partial for the render:

My_View_Helper_PageEdit extends Zend_View_Helper_Abstract
{
  public function PageEdit ($element)
  {
    $form = new Zend_Form;
    $form->addElement('tinyMce', 'textarea' . $element->id, array($options));
    return $this->view->partial('partial.phtml', array('form' => $form));
  }
}

And inside the partial your html :)

Regards, Jurian
-- 
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

Reply via email to