2010-03-30 3 views

Antwort

8
$this->partial('directoryOfPartials/partial.phtml', $model); 

Ich glaube, Sie auch $ this-> Teil mit drei Argumenten verwenden können. Das zweite Argument ist ein Modulname und das dritte Argument wird zum Modell.

entnommen aus: http://framework.zend.com/manual/en/zend.view.helpers.html

Example #10 Rendering Partials in Other Modules Sometime a partial will exist in a different module. If you know the name of the module, you can pass it as the second argument to either partial() or partialLoop(), moving the $model argument to third position. For instance, if there's a pager partial you wish to use that's in the 'list' module, you could grab it as follows:

<?php echo $this->partial('pager.phtml', 'list', $pagerData) ?> 

In this way, you can re-use partials created specifically for other modules. That said, it's likely a better practice to put re-usable partials in shared view script paths.

EDIT - Zugriff auf Ansicht partials innerhalb eines Aktions Rahmen des Controllers

$this->view->getHelper('partial')->partial('comments.phtml'); 
+0

Danke, das ist großartig für die Ansicht, jedoch habe ich eine Abfrage darüber über den Controller, antworten in einem neuen posten Sie unten, um klarer zu sein – azz0r

+0

was zu tun, wenn Sie teilweise in Helfer einstellen? Ich meine danach, was du nach deinem Schnitt gepostet hast? Sie setzen partiell auf comments.phtml, aber was damit in Sicht zu tun? TIA – prostynick

2

Excellent thanks :)

aber wie soll ich tun dies über Der Controller? Ich habe fancybox und habe das Ajax-Layout einrichten:

$this->view->layout()->setLayout('ajax'); 

$errors = array('You have lost your rights to download this clip, you have downloaded it the maximum amount of times.'); 

$this->render($this->view->partial('partials/errors.phtml', 'default', array('errors' => $errors)), NULL, true); 

Die Pop-up-Fenster je nach Bedarf aber mit dem folgenden Fehler:

Problem: Method "partial" does not exist and was not trapped in __call() 

ich irgendwie angenommener den $ this-> view-> Teil wäre das gleiche wie die Verwendung von $ this-> partially in der Ansichtsvorlage, aber ich denke nicht. Ideen?

GELÖST VIA:

Bootstrap initview, fügte hinzu:

$view->addScriptPath('../application/layouts/partials'); 

Verschoben mein partials in dieses Verzeichnis. Da ist in meinem Controller ich tun:

$this->view->layout()->setLayout('ajax'); 
$this->view->form = $form; 
$this->renderScript('login.phtml'); 

Dank geht an #zftalks SmartSsa

+1

$ this-> view-> getHelper ('partiell') -> partiell ('comments.phtml'); Ich habe es auch meiner Antwort hinzugefügt. – Ballsacian1