1

custom.tpl.php に固有の $variables を前処理するにはどうすればよいですか?

次のように theme_hook_suggestions を実装する hook_preprocess_node があります

function customtheme_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}

そして、node_ contentType __viewModeの HTML を返す関数

function customTheme_node__article__full($variables) {
  $output = '';

  //build output markups ....

  $output .= render($variables['content']);
  return $output;
}

上記の viewMode テーマを具体的に対象とする前処理関数が必要だとしましょう。

私が試してみました

function customeTheme_preprocess_node__article__full(&$variables) {}

しかし、うまくいかないようでした。

4

2 に答える 2

1

私はこれをテストしていませんが、メインの関数から独自のカスタム前処理関数を呼び出すことができます:

function customtheme_preprocess_node(&$variables) {
  $preprocess_mode = __FUNCTION__ . '__' . $variables['type'] . '__' . $variables['view_mode'];
  if (function_exists($preprocess_mode)) {
    $preprocess_mode($variables);
  }
  $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}
于 2014-04-02T20:29:11.023 に答える