1

私が欲しいものはとてもシンプルです。パスを登録しました

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 を変更せずに) ?

4

1 に答える 1

1

taxonomy_term_page用語をロードするロード関数を提供する必要があるため、 your として直接呼び出すことはできません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);
}
于 2011-12-01T10:27:03.460 に答える