template.php 대신 모듈에서 전처리하고 주제를 전제하고 싶습니다. 전에는 theme_preprocess_node()
에 거대한 switch 문을 넣었습니다. 하지만 이것은 기본 탭에만 적용되었습니다. 하위 탭은 정의 된 모듈에서 템플리트를 작성했습니다. 따라서 모든 사전 처리 기능과 템플리트를 하나의 구성 모듈로 통합하는 것이 좋습니다.모듈의 전처리 노드 : template.php와 같은 노드를 가지지 않습니다.
내가 원하는 구조는 다음과 같이 본질적으로 (요약에 대한 세부 사항을 당겨) :
function foomodule_menu()
{
$items['foo/%node'] = array(
'page callback' => 'page_foo_overview',
'page arguments' => array(1),
'type' => MENU_NORMAL_ITEM,
);
$items['foo/%node/overview'] = array(
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['foo/%node/details'] = array(
'page callback' => 'page_foo_details',
'page arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
}
function foomodule_theme()
{
return array(
'page_foo_overview' => array(
'arguments' => array('node' => NULL),
'template' => 'templates/page-foo-overview'
),
'page_foo_details' => array(
'arguments' => array('node' => NULL),
'template' => 'templates/page-foo-details'
),
);
}
function page_foo_overview($node)
{
// Used to do this, and themed it from template.php
// return node_view($node, FALSE, TRUE);
// Instead, I'd like to theme all pages directly in this module:
return theme('page_foo_overview', $node);
}
function template_preprocess_page_foo_overview(&$vars)
{
// But $vars doesn't contain the same data as when I themed from template.php
// Specifically the ['view'] element of CKK fields, and flags like $teaser
// What do I need to do to get at the same data?
dsm($vars);
}
모든 잘 작동하지만, $ 내가에 익숙해하지 않는 것을 내 전처리에서 사용할 수 바르 template.php의 theme_preprocess_node()
기능. 하나는 CCK 필드가 content_format()
([view '] 요소 없음)을 통해 실행되지 않았으며 teaser
및 page
과 같은 플래그가없는 것 같습니다.
내가 여기서 호출 할 수있는 theme_preprocess_node()
전에는 무엇이 호출되고 있습니까?
이렇게하면 문제가됩니까? 메뉴> 페이지 콜백> 테마> 전처리> 템플릿과 같이 각 단계를 제어하고이를 여러 개의 모듈에 걸쳐 적절히 구성 할 수 있도록 구성하는 것이 훨씬 더 합리적입니다.