2011-01-18 44 views
0

我想從模塊,而不是template.php預處理和主題我的節點。之前,我會在theme_preprocess_node()有一個巨大的開關聲明。但是這隻適用於我的主選項卡 - 子模塊是從它們定義的模塊中模板化的。所以我喜歡將所有預處理函數和模板合併到一個有組織模塊中的想法。從模塊預處理節點:沒有得到相同的變量作爲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()(no ['view']元素),並且像teaserpage這樣的標誌丟失。

theme_preprocess_node()之前是什麼叫我可以在這裏調用?

我是不是要問這個問題?對我來說,讓它像這樣組織起來,並控制每一步:菜單>頁面回調>主題>預處理>模板,並且能夠按照我認爲合適的方式將其組織在多個模塊中。

回答

1

AK,

我的建議是執行下面的代碼來檢查可用變量

<?php 
$arr = get_defined_vars(); 
dsm($arr); 
?> 

如果不幫助你可以檢查你的模塊的重量在系統表。也許改變它(讓你的模塊在其他模塊之後運行)可以幫助你。