Доброго времени суток!
Уважаемое сообщество, крайне не люблю отнимать ваше время, но ситуация требует.
Задача такова: Нужно создать блок с формой. Все это через свой модуль.
Все готово, дело за малым - нужно подключить свой шаблон для этого блока. он должен быть в папке с модулем. Делаю все на гарланде, скопировал шаблон из папки темы гарланд, вставил в папку с модулем, дал имя по типу block-moduleName.tpl.php изменил его чуть чуть, чтоб увидеть или он включается..по идее друпал должен съесть его, но не как не ест...
вопрос: ----КАК ЕГО СКОРМИТЬ ДРУПАЛУ В КОНЦЕ КОНЦОВ???----
подключаю так:
но увы, всеравно друпал берет свой стандартный block.tpl.php
Комментарии
Для D7
1 вариант - используйте hook и творчески переработайте содержимое
<?php
// Create the $content variable that templates expect.
$variables['classes_array'][] = drupal_html_class('block-' . $variables['block']->module);
$variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region;
// Create a valid HTML ID and make sure it is unique.
/**
* Processes variables for block.tpl.php.
*
* Prepares the values passed to the theme_block function to be passed
* into a pluggable template engine. Uses block properties to generate a
* series of template file suggestions. If none are found, the default
* block.tpl.php is used.
*
* Most themes utilize their own copy of block.tpl.php. The default is located
* inside "modules/block/block.tpl.php". Look in there for the full list of
* variables.
*
* The $variables array contains the following arguments:
* - $block
*
* @see block.tpl.php
*/
function myModule_preprocess_block(&$variables) {
$block_counter = &drupal_static(__FUNCTION__, array());
$variables['block'] = $variables['elements']['#block'];
// All blocks get an independent counter for each region.
if (!isset($block_counter[$variables['block']->region])) {
$block_counter[$variables['block']->region] = 1;
}
// Same with zebra striping.
$variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even';
$variables['block_id'] = $block_counter[$variables['block']->region]++;
$variables['content'] = $variables['elements']['#children'];
$variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module;
// Hyphens (-) and underscores (_) play a special role in theme suggestions.
// Theme suggestions should only contain underscores, because within
// drupal_find_theme_templates(), underscores are converted to hyphens to
// match template file names, and then converted back to underscores to match
// pre-processing and other function names. So if your theme suggestion
// contains a hyphen, it will end up as an underscore after this conversion,
// and your function names won't be recognized. So, we need to convert
// hyphens to underscores in block deltas for the theme suggestions.
$variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . strtr($variables['block']->delta, '-', '_');
$variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);
}
?>
2 вариант - используйте , его помощью можно "выше" уровнем переопределить любую темизация
* Alter the theme registry information returned from hook_theme().
*
* The theme registry stores information about all available theme hooks,
* including which callback functions those hooks will call when triggered,
* what template files are exposed by these hooks, and so on.
*
* Note that this hook is only executed as the theme cache is re-built.
* Changes here will not be visible until the next cache clear.
*
* The $theme_registry array is keyed by theme hook name, and contains the
* information returned from hook_theme(), as well as additional properties
* added by _theme_process_registry().
*
* For example:
* @code
* $theme_registry['user_profile'] = array(
* 'variables' => array(
* 'account' => NULL,
* ),
* 'template' => 'modules/user/user-profile',
* 'file' => 'modules/user/user.pages.inc',
* 'type' => 'module',
* 'theme path' => 'modules/user',
* 'preprocess functions' => array(
* 0 => 'template_preprocess',
* 1 => 'template_preprocess_user_profile',
* ),
* );
* @endcode
*
* @param $theme_registry
* The entire cache of theme registry information, post-processing.
*
* @see hook_theme()
* @see _theme_process_registry()
*/
function hook_theme_registry_alter(&$theme_registry) {
// Kill the next/previous forum topic navigation links.
foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_topic_navigation') {
unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
}
}
}