यहां एक फ़ंक्शन है जो आपको गतिशील रूप से नए जोड़ने की अनुमति देता है। यदि आपने एक घोषित किया है तो यह संबंधित प्रीप्रोसेस फ़ंक्शन को भी कॉल करता है।
फिर drush cache-clear theme-registryइसे काम करने के लिए कॉल करें ।
अपने विषय के नाम के साथ इसे बदलने के लिए उपयोग करने के लिए, और इसे अपने विषयों में रखें। फ़ाइल।
उदा। Droid नामक थीम के लिए आप इसे कॉल करेंगे droid_preprocess_node(&$variables, $hook) {...
function THEME_preprocess_node(&$variables, $hook) {
$view_mode = $variables['view_mode'];
$content_type = $variables['type'];
$variables['theme_hook_suggestions'][] = 'node__' . $view_mode;
$variables['theme_hook_suggestions'][] = 'node__' . $view_mode . '_' . $content_type;
$view_mode_preprocess = 'THEME_preprocess_node_' . $view_mode . '_' . $content_type;
if (function_exists($view_mode_preprocess)) {
$view_mode_preprocess($variables, $hook);
}
$view_mode_preprocess = 'THEME_preprocess_node_' . $view_mode;
if (function_exists($view_mode_preprocess)) {
$view_mode_preprocess($variables, $hook);
}
}