2012-02-25 134 views
0

以下結構:Symfony的1.4路徑模塊

apps/backend/ 
apps/frontend/ 
      modules/ 
        account/template/_menu.php 
        account/template/test.php 
        settings/template/indexSuccess.php 

我做包括_menu在用下面的代碼test.php的:

<?php slot('menu'); ?> 
<?php include(dirname(__FILE__).'/_menu.php') ; ?> 
<?php end_slot() ?> 

我怎麼能包括indexSuccess文件_menu.php。 PHP的? 謝謝!

貢納爾

回答

1

你想用include_partial從indexSuccess.php的模板:

// indexSuccess.php 
// Use the array container to pass values available in indexSuccess to your partial 
<?php include_partial('menu', array(
    'foo' => $foo, 
    'bar' => $bar 
)) ?> 

您可以在Symfony API Docs閱讀更多關於它。

+1

您不需要,Symfony會在/ apps/app_name/templates(全局)或/ apps/app_name/modules/module_name/templates中的其中一個位置查找。所以你需要做的是確保你的部分(用'_'表示)位於這兩個位置之一。 – 2012-02-25 18:17:22

+0

你有工作嗎? – 2012-02-25 22:10:36

+0

是的,我做到了!謝謝! – craphunter 2012-02-27 23:18:29