http://www.drupalchina.org/node/2190
以下是firehare 貼出的code
<?php
$output = "
- ";
- ".$pm_item['title']."";
if (count($pm_item['children']) != 0) {
$output .= "";
}
$output .="
$pri_menu = menu_get_item(2);
$pm_links = array();
foreach($pri_menu['children'] as $pmid) {
$pm_item = menu_get_item($pmid);
$pm_links[$pm_item['weight']] = $pm_item;
foreach($pm_item['children'] as $smid) {
$sm_item = menu_get_item($smid);
$pm_links[$pm_item['weight']]['sm_links'][$sm_item['weight']] = $sm_item;
}
ksort($pm_links[$pm_item['weight']]['sm_links']);
}
ksort($pm_links);
foreach($pm_links as $pm_item) {
$output .= "
";
}
$output .= "
";
print $output;
?>
我的站有以下primary links
Home -----> node/1
Company Profile -----> node/2
Services -----> node/3
Calculation -----> node/4
News -----> node/5
Message Board -----> node/6
Partners -----> node/7
Contact Us -----> node/8
問題是,當我初次瀏覽站,按任何一個link 顯示該content,但再按其他links 時發覺url 會加多個 /node
e.g.
第一次按home
http://www.mysite.com/node/1
第二次按Service
http://www.mysite.com/node/node/3
第三次按home
http://www.mysite.com/node/node/node/1
即有個/node/ 會不斷increament
Re: 用了firehare 寫的code 來自行產生primary links 連 subitems, 但好像有點問題
看到drupal 有warnings, 是這段code 的.
# warning: Invalid argument supplied for foreach() in /usr/local/ttl_drupal/themes/ttl/page.tpl.php on line 50.
# warning: ksort() expects parameter 1 to be array, null given in /usr/local/ttl_drupal/themes/ttl/page.tpl.php on line 54.
Re: 用了firehare 寫的code 來自行產生primary links 連 subitems, 但好像有點問題
原本的選單應該會把網站路徑加上的,可能漏掉某段 code...
可以改用 /node/1 這種形式嗎?
Re:
可以啊.............
那麼如果解決???? 是那段code snippet 有bug 嗎????