首頁 › 在template_preprocess_comment加class
在template_preprocess_comment加class
範例說明:
User reference指定使用者回應時設高亮!內容類型「比賽」裡面有User reference欄位「主辦單位」,對應到主辦單位的User Id。
需求:
希望該比賽的回應,若是主辦單位(User Reference)回應的話,則讓他變成白底。
作法:
1.在theme的template.php裡面加上
function longhair_preprocess_comment(&$vars, $hook) { if(arg(0) == 'node'){ $node = node_load(arg(1)); if($node->type =='match' && $vars['comment']->uid == $node->field_operator_bhuntr[0]['uid']){ $vars['classes_array'][] = 'operator'; } } }
2.在CSS寫上
#comments .operator{ background-color: #FFFAEF; }
完成!

- 人氣(6929)
Recent Comments
熱門內容
- Drupal | 用hook_menu_alter來修改tab項目 (206,105)
- 第一次玩弄Drupal就不上手 (196,310)
- 六個網站測速工具 (118,251)
- Drupal 的 Eye Candy? (91,345)
- Introduction to Drupal 簡報分享 (39,410)
找我聊聊
敲我MSN吧!
若我MSN下班,搞不好在這
或是在這












