Drupal Dynamic Internal Redirect
質問
私が欲しいものは非常に簡単です。パスを登録しました
function spotlight_menu() {
$items = array();
$items['congres'] = array(
'title' => 'Congres',
'title arguments' => array(2),
'page callback' => 'taxonomy_term_page',
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
このメニュー項目がトリガーされたら、(URLを変更せずに)分類ページにリダイレクトしたいと思います。この機能は、この関数が呼び出されたときに実行される関数で選択されます。
どうすればこれを行うことができますか(特にURLを変更せずに)?
解決
電話することはできません taxonomy_term_page
あなたのように直接 page callback
用語をロードするために負荷関数を提供する必要があるため、これはあなたが持っているセットアップではあまりにも難しくなります。
代わりに、独自のページコールバックを仲介者として定義し、から出力を返すだけです taxonomy_term_page
直接:
function spotlight_menu() {
$items = array();
$items['congres'] = array(
'title' => 'Congres',
'page callback' => 'spotlight_taxonomy_term_page',
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function spotlight_taxonomy_term_page() {
// Get your term ID in whatever way you need
$term_id = my_function_to_get_term_id();
// Load the term
$term = taxonomy_term_load($term_id);
// Make sure taxonomy_term_page() is available
module_load_include('inc', 'taxonomy', 'taxonomy.pages');
// Return the page output normally provided at taxonomy/term/ID
return taxonomy_term_page($term);
}
所属していません StackOverflow