2010-08-06 29 views

回答

1

你對模塊開發有多熟悉?我會建議更簡單,不那麼即時的方式。如果您確實希望僅在添加新節點時更新它,則需要更多的工作。如果有人想描述這一點,他們是不是歡迎。

真的所有你需要寫一個塊(hook_block),它inputs some javascript其中:

  • 發送Ajax查詢頁面的模塊定義(比如/節點/新)
  • 顯示的數據該塊(通過ajax回調)。
  • 使用set_timeout javascript調用每隔一段時間再次進行一次調用。

該頁面將在一個呼叫hook_menu與「類型」 => MENU_CALLBACK並調用自定義函數(my_module_nodes_new)來定義。

function my_module_nodes_new() { 
    $output = ''; 
    $result = db_query("SELECT nid FROM {node} WHERE status = 1 LIMIT 5 ORDER BY `created` DESC"); 
    while($nid = db_fetch_object($result) { 
    $node = node_load($nid->nid); 
    // Theme the information here and add it to $output 
    } 

    print $output; //IMPORTANT - do not "return" $output or it will be inside your theme 
} 

希望有幫助!

相關問題