2011-04-11 130 views
0
function rate_preprocess_rate_template_emotion(&$variables) { 
    extract($variables); 
    $buttons = array(); 
    foreach ($links as $link) { 
    $button = theme('rate_button', $link['text'], $link['href'], 'rate-emotion-btn'); 
    $button .= $link['votes']; 
    $buttons[] = $button; 
    } 
    $variables['buttons'] = $buttons; 

    $info = array(); 
........ 

現在我想添加<br/><span class="pollunm">圍繞</span>。我把這段代碼放在我的主題template.php中,但它不輸出span標籤。爲什麼覆蓋沒有輸出?

function mytheme_preprocess_rate_template_emotion(&$variables) { 
$link['votes']='<br/><span class="pollunm">'.$link['votes'].' </span>'; 
} 

+0

你的主題叫做'mytheme'嗎?如果不將「mytheme」更改爲任何主題的名稱(主題文件夾中的.info文件)。您是否已在管理員的「效果」部分清除了緩存的數據? – 2011-04-11 11:45:47

+0

yeap,主題文件被稱爲mytheme,我清除了緩存。 – zhuanzhou 2011-04-11 12:02:31

+0

是mytheme_preprocess_rate_template_emotion()真的叫做_before_ rate_preprocess_rate_template_emotion()嗎? – gpilotino 2011-04-11 13:30:00

回答

0

這不是一個解決方案。只是你調試的步驟。

  1. 首先確保function mytheme_preprocess_rate_template_emotion(&$variables)通過在函數中放入dpm(install devel module)來調用。他們使用foreach ($links as $link)。因此,確保你是否想要爲所有鏈接做到這一點只是一個鏈接。
  2. function mytheme_preprocess_rate_template_emotion(&$variables)之內放了一個dpm($ variables);並找出哪些是您可以使用的變量以及它們的值是什麼。它可能會幫助你。
相關問題