2010-03-30 16 views
7

वर्तमान में मुझे लगता है कि मुझे विभिन्न मॉड्यूल के लिए आंशिक भाग को डुप्लिकेट करना है।आंशिक Zend फ्रेमवर्क आंशिक के आधार के साथ

मैं सभी आंशिक लोगों तक पहुंचने के लिए एक केस निर्देशिका रखना चाहता हूं।

क्या किसी के पास ऐसा करने का एक अच्छा तरीका है?

धन्यवाद

उत्तर

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

मुझे लगता है कि आप भी $ this-> तीन तर्क के साथ आंशिक उपयोग कर सकते हैं। दूसरा तर्क एक मॉड्यूल नाम है और तीसरा तर्क मॉडल बन जाता है। एक नियंत्रक कार्रवाई दायरे के भीतर से एक्सेस करना दृश्य partials

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

धन्यवाद, इस दृश्य के लिए बहुत अच्छा है, लेकिन मैं नियंत्रक के माध्यम से इसे का उपयोग के बारे में प्रश्न हैं, एक नया में जवाब देगा नीचे – azz0r

+0

स्पष्ट होने के लिए नीचे पोस्ट करें जब आप सहायक में आंशिक सेट करते हैं तो क्या करना चाहिए? मेरा मतलब है, आपके संपादन के बाद आपने क्या पोस्ट किया? आप comments.phtml पर आंशिक सेट करते हैं, लेकिन इसके साथ क्या करना है? टीआईए – prostynick

2

बहुत बढ़िया धन्यवाद :)

हालांकि, कैसे मैं इस करते हैं के माध्यम से - 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.

संपादित करें:

से लिया नियंत्रक? मैं fancybox है और ajax लेआउट की स्थापना की है:

$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); 

पॉप अप विंडो के रूप में आवश्यक है, लेकिन निम्न त्रुटि के साथ:

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

मैं थोड़े की $ this-> देखें> आंशिक ग्रहण व्यू टेम्पलेट के अंदर आंशिक $> का उपयोग करने जैसा ही होगा, लेकिन मुझे लगता है कि नहीं। विचार?

हल के माध्यम से:

बूटस्ट्रैप initView, कहा:

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

कि निर्देशिका करने के लिए अपने partials ले जाया गया। तब मेरे नियंत्रक में मुझे क्या करना:

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

धन्यवाद #zftalks लिए बाहर चला जाता SmartSsa

+1

$ यह-> देखें-> getHelper ('आंशिक') -> आंशिक ('comments.phtml'); मैंने इसे अपने उत्तर में भी जोड़ा। – Ballsacian1

संबंधित मुद्दे