Drupal 7

Bye, bye region.tpl.php and block--system--main.tpl.php

/**
* Implements hook_page_alter().
*/
function mytheme_page_alter(&$page) {
// Remove all the region wrappers.
foreach (element_children($page) as $key => $region) {
if (!empty($page[$region]['#theme_wrappers'])) {
$page[$region]['#theme_wrappers'] = array_diff($page[$region]['#theme_wrappers'], array('region'));
}
}
// Remove the wrapper from the main content block.
if (!empty($page['content']['system_main'])) {

The code has been tested and works

Управление файлами в Drupal7

/**
* our example system settings form
*/
function mf_settings_form($form,&$form_state) {
$form = array();

$form['managed_file_example'] = array(
'#type' => 'managed_file',
'#title' => t('Managed File Example'),
'#default_value' => variable_get('managed_file_example',''),
'#upload_location' => 'public://managed_file_example/',
);

$form = system_settings_form($form);
$form['#submit'][] = 'mf_settings_submit';

return $form;
}

The code has been tested and works

Создаем стиль для картинок программно Drupal7

$style = image_style_save(array('name' => 'avatar'));
$effect = array(
'name' => 'image_scale',
'data' => array(
'width' => 64,
'height' => 64,
'upscale' => TRUE,
),
'isid' => $style['isid'],
);
image_effect_save($effect)

The code has been tested and works

Изменяем форму в виджете поля Drupal7

function MYMODULE_field_widget_form_alter(&$element, &$form_state, $context) {
// If this is an image field type
if ($context['field']['type'] == 'image') {
// Loop through the element children (there will always be at least one).
foreach (element_children($element) as $key => $child) {
// Add the new process function to the element
$element[$key]['#process'][] = 'MYMODULE_image_field_widget_process';
}
}
}

The code has been tested and works

Парсинг материалов вконтакте Feeds drupal7

Точка входа на api вконтакта находится здесь.

https://api.vk.com/method

Документация https://vk.com/dev/openapi

Мы будем использовать https://vk.com/dev/wall.get метод для работы со стеной группы или пользователя

The code has been tested and works

Удаляем табы на странице регистрации Drupal7

Задача - убрать вкладки над формой регистрации.

Решение - hook_menu_alter()
function custom_menu_alter(&$items) {
$items['user']['type'] = MENU_CALLBACK;
$items['user/register']['type'] = MENU_CALLBACK;
$items['user/password']['type'] = MENU_CALLBACK;
}

The code has been tested and works

Пишем свой style-plugin для Views

Реализуем хук hook_views_api(), в котором возвращаем версию Views API:

/**
* Implements hook_views_api().
*/
function views_style_example_views_api() {
return array('api' => 3);
}

В файле modulename.views.inc реализуем хук hook_views_plugins(), в котором возвращаем информацию о плагине:

The code has been tested and works

Добавляем библиотеку с помощью hook_library

/**
* Implements hook_library().
*/
function mymodule_library() {
// path to files "my_library" sites/all/libraries/my_library

// then the path "my_library" can get
// use function drupal_get_path('module', 'mymodule')
$my_library_path = libraries_get_path('my_library');

$libraries['my_library'] = array(
// name variable
'title' => t('My_library'),

The code has been tested and works

Pages

Subscribe to RSS - Drupal 7