Nikitsaid सही है।
मैं जोड़ूंगा कुछ हुक हैं जिन्हें परिभाषित करने की अनुमति है कि कौन सी फाइलों को लोड करने की आवश्यकता है। ऐसे हुक के उदाहरण hook_theme()
, और hook_menu()
हैं।
एक मॉड्यूल को किसी फ़ाइल को बिना शर्त रूप से लोड करना चाहिए जिसे उसे किसी फ़ंक्शन के बाहर से module_load_include()
पर कॉल करने की आवश्यकता है।
function book_menu() {
$items['admin/content/book'] = array(
'title' => 'Books',
'description' => "Manage your site's book outlines.",
'page callback' => 'book_admin_overview',
'access arguments' => array('administer book outlines'),
'file' => 'book.admin.inc',
);
$items['admin/content/book/list'] = array(
'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/content/book/settings'] = array(
'title' => 'Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('book_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 8,
'file' => 'book.admin.inc',
);
// …
}
function user_theme() {
return array(
'user_picture' => array(
'arguments' => array('account' => NULL),
'template' => 'user-picture',
),
'user_profile' => array(
'arguments' => array('account' => NULL),
'template' => 'user-profile',
'file' => 'user.pages.inc',
),
// …
'user_admin_perm' => array(
'arguments' => array('form' => NULL),
'file' => 'user.admin.inc',
),
// …
);
}
लेकिन मेरा मुख्य इरादा कई डेटा एक्सेस फ़ंक्शंस के बारे में है जो विभिन्न भागों में उपयोग किए जाते हैं। जैसे टिप्पणियाँ। 'comment_total_count()', 'comment_today_count()' टेम्पलेट्स में उपयोग किया जाता है, 'comment_thread() 'व्यवस्थापक पृष्ठ के साथ-साथ सामग्री पृष्ठ पर भी आवश्यक है। व्यवस्थापक पृष्ठ पर 'comment_remove() 'और' comment_edit() 'के दौरान सामग्री पृष्ठ पर' comment_insert()'। क्या मुझे परंपरागत 'आवश्यकता' या 'शामिल' वाक्यविन्यास का उपयोग करने की आवश्यकता है? और एकाधिक फ़ाइलों को शामिल करने के बारे में क्या? –
PHP फ़ाइलों को शामिल करने के लिए उपयोग किया जाने वाला फ़ंक्शन ['module_load_include()'] (http://api.drupal.org/api/function/module_load_include/6) है। आप एक, या अधिक फाइलों को शामिल कर सकते हैं। – kiamlaluno