[英]drupal theme_preprocess_node function not getting executed from template file
[英]Drrupal 7 theme_preprocess_node
在Drupal顯示節點內容之前,我需要更改標題和正文。
我可以使用主題preprocess_node更改並查看新標題。 我可以使用相同的my_theme_preprocess_node進行更改,但看不到頁面中的新主體。
使用dpm可以看到主體已更改,但是在頁面中主體是相同的。
如何在正文頁面內容中看到正文更改?
function my_theme_preprocess_node(&$variables) {
if ($variables['title'] == "my node title") {
$variables['title'] = 'my new node title';
$variables['body'][0]['value'] = 'my new body content';
}
}
您應該使用hook_node_view_alter修改您的正文字段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.