首頁 › [Drupal] 在頁面的tabs新增獨特class
[Drupal] 在頁面的tabs新增獨特class
Drupal的menu系統有一個Local menu task,會顯示目前頁面的相關頁面,如圖:

上圖中紅色框起來的地方就是Tabs (Local menu task)。我是如何作到其中幾個是紅字呢?
一般來說,若你希望能分別使用CSS自訂Tabs的樣式,預設的class可能會不夠用。
這時可以在template.php加上以下原始碼:
<?php function phptemplate_menu_local_task($link, $active = FALSE) { //取a元素的href preg_match('/\"[^\"]*\"/', $link, $matches ); $matches[0] = substr ( $matches[0] , 2 , strlen($matches[0]) - 3 ); $path_head = substr( $matches[0], 0, strpos( $matches[0], "/")); $path_tail = substr( strrchr( $matches[0], "/" ), 1 ); //把 /user/me 變成 user-me $results[0] = str_replace('/', '-', $results[0]); //print_r $admin = user_access('administer users'); if($admin){ //drupal_set_message('<pre>' . $path_head . '-' . $path_tail . '</pre>'); } $tab_class = $path_head . '-' . $path_tail; //增加獨特 ID static $mid = 0; $mid += 1; $moon_cake = 'bhuntr-' . $mid; return '<li class="' . $tab_class . ' ' . $moon_cake. ($active ? ' active"' : '"') .'>'. $link ."</li>\n"; } ?>
這樣每個li就會生成獨特的class,再用CSS調整就再容易不過了。
- 人氣(3779)
Recent Comments
熱門內容
- Drupal | 用hook_menu_alter來修改tab項目 (192,708)
- 第一次玩弄Drupal就不上手 (183,799)
- 六個網站測速工具 (103,107)
- Drupal 的 Eye Candy? (71,120)
- Introduction to Drupal 簡報分享 (35,917)
找我聊聊
敲我MSN吧!
若我MSN下班,搞不好在這
或是在這













回應
ezCpEV sdvtzvyhdimm, [url=http://zmczmytzuleu.com/]zmczmytzuleu[/url], [link=http://ibbgowuqtzzc.com/]ibbgowuqtzzc[/link], http://qgnkbkcheleo.com/
q4lwAW dgeabkccrsuf, [url=http://zpikoimvxcdy.com/]zpikoimvxcdy[/url], [link=http://ypbgbmggconm.com/]ypbgbmggconm[/link], http://atwexsezwsoh.com/
YW5RlT hfqfrfbeofsg, [url=http://ywbatzaofukj.com/]ywbatzaofukj[/url], [link=http://tavjsacmlhvp.com/]tavjsacmlhvp[/link], http://dngmriacpumz.com/
E7sKlp fyvcxqbqqpmy, [url=http://cneugicasssw.com/]cneugicasssw[/url], [link=http://pungpgqrophu.com/]pungpgqrophu[/link], http://qhoqqkltiwkk.com/
Don't you know that this is the best time to get the loan, which would realize your dreams.
發表新回應