Error message

User warning: The following theme is missing from the file system: responsive_green. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1143 of /var/www/


The best way to add a column to an existing table in drupal

* Implements hook_schema_alter().
function mymodule_schema_alter(&$schema) {
$schema['tablename']['fields']['fieldname'] = array(
'type' => 'varchar',
'default' => null

* Implements hook_install().
function mymodule_install() {
if (!db_field_exists('tablename', 'fieldname')) {
$schema = drupal_get_schema('tablename');
db_add_field('tablename', 'fieldname', $schema['fields']['fieldname']);

The code has been tested and works

Настройка cron для Drupal7(Debian7)

Системный крон сервера.
Что бы настроить запуск системного крона, нужно в файл .crontab, прописать строчку с временем запуска и именем файла который нужно будет запустить(в нашем случае это cron.php).
Для этого нужно будет убедится , что процесс запущен.

ps ax |grep cron

При необходимости загружаем пакеты

apt-get install cron

The code has been tested and works

Програмно переводим сущности(entity)

Перевод сущности темина таксономии и его полей
//Translate term ru
$lang_first = 'ru';

$lang = array('en','ru');
$term_title = $term->name_field['en'][0]['value'];
$translate_term_title =custom_translate_data($lang,$term_title);
$translate_term_title = $translate_term_title['text'][0];
$term_title = $term->name_field['ru'][0]['value'] = $translate_term_title;

$handler = entity_translation_get_handler('taxonomy_term', $term);

The code has been tested and works

Getting the node ID of a page making a $.post request

function mymodule_node_view($node, $view_mode, $langcode) {
if ($view_mode == 'full') {
$setting = array('mymodule' => array('currentNid' => $node->nid));
drupal_add_js($setting, 'setting');

Then on the client side you'll have access to it through Drupal.settings:

var currentNid = Drupal.settings.MYMODULE.currentNid;

The code has been tested and works

Значение по умолчанию для раскрытых фильтров

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
if (!isset($form_state['view']->exposed_input[''])) {
// $form_state['view']->exposed_input only hold the value when you have applied any filter. Initially it doesn't hold any value. while $form_state['input'] hold the actual filter value to be applied.
$form_state['input'][''] = '';

The code has been tested and works

Install coder and php-codesniffer

Install Coder with Drush

First, make sure Drush is installed correctly:

$ which drush

If you get drush not found or similar, follow Drush's installation instructions.
Now install Coder to Drush's central store:

$ drush pm-download coder --destination=$HOME/.drush

Clear drush's internal cache so it sees Coder:

$ drush cache-clear drush

The code has been tested and works

Setting up PhpStorm for Drupal's Coding Standards


Although not related to Drupal, the Keymap is the first thing I change. By default, PhpStorm comes with keyboard shortcuts I find very unnatural. Under Preferences, scroll down to select Keymap on the left, and select the keymap that suits your needs. Mac OS X 10.5+ feels the most intuitive to me. You can also further customize the keyboard shortcuts to each of the actions.


Syntax and Formatting

The code has been tested and works

Добавляем поддержку стандартов кодирования drupal в PhpStorm

Раскладка клавиатуры
Используем раскладку Mac OS X 10.5+


Синтаксис и форматирование

Drupal стандарты рекомендуют менее 80 символов в строке



В PhpStorm можно выставить предопределенный стиль для php - Drupal.

The code has been tested and works


Subscribe to RSS - drupal