您在這裡

用了firehare 寫的code 來自行產生primary links 連 subitems, 但好像有點問題

adrianmak's 的頭像
adrianmak 在 2007-05-24 (四) 07:18 發表

http://www.drupalchina.org/node/2190
以下是firehare 貼出的code

<?php

$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 .= "

  • ".$pm_item['title']."";
    if (count($pm_item['children']) != 0) {
    $output .= "

    ";
    }
    $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