2010-04-13 44 views
2

我該如何繞過.tpl文件重寫主題功能?我知道如何用主題功能覆蓋.tpl文件,但不是相反。我似乎無法找到任何能夠告訴我的地方,所以也許這是不可能或不好的做法。我可以用.tpl文件覆蓋主題函數嗎?

例如,如果有一個叫做super_results並與主題註冊表中註冊模塊中定義的主題功能,如下面的例子,我怎麼會去周圍super_results.tpl.php覆蓋它。

'super_results' => array(
     'arguments' => array('title' => NULL, 'results' => NULL, 'votes' => NULL), 
    ), 

function modulename_super_results($title, $results,$votes){ output HTML } 

回答

3

最簡單的解決方案可能是創建一個使用模板的新主題功能。類似的東西應該可以工作,免責聲明代碼未經測試。

function my_theme_theme() { 
    return array(
    'overide' => array(
     'template' => 'elm-super_results', 
     'arguments' => array('title' => NULL, 'results' => NULL, 'votes' => NULL), 
    ), 
); 
} 

function my_theme_super_results($title, $results, $votes) { 
    return theme('overide', $title, $results, $votes); 
} 
+0

這是血腥的聰明。感謝Googletorp :) – screenm0nkey 2010-04-13 16:20:29

相關問題