我試圖通過編程向所有主鏈接添加查詢字符串「?device = mobile」。Drupal6:將查詢字符串附加到主鏈接
在我試過下面我主題的page.tpl.php中的文件,
<?php if (is_array($primary_links)) : ?>
<?php foreach ($primary_links as $link): ?>
$link['href'] = $link['href'].'?device=mobile';
<?php endforeach; ?>
<?php endif; ?>
然而,這只是輸出代碼到頁面上。目前我正在嘗試使用hook_menu_link_alter,但到目前爲止我還沒有成功。要測試我的代碼僅在一個主鏈接項目上,我試過以下代碼:
myModule_menu_link_alter(&$item, $map){
$items['photo_gallery']['href'] = 'photo_gallery?device=mobile';
}
不幸的是鏈接沒有變化。我也將從我的template.php文件中調查hook_menu_item_link(),但是在這一點上,如果有人能指引我朝着正確的方向,並且讓我知道我做錯了什麼,我會喜歡它。
謝謝。
謝謝亞歷山大!這是一個很大的幫助! – SFox 2012-07-10 03:02:23