14.02 2017

В ckeditor.config.js добавить

CKEDITOR.on('instanceReady', function (ev) {
  ev.editor.dataProcessor.htmlFilter.addRules( {
    elements : {
      table : function( element ) {
          element.attributes.class = 'table';
      }
    }
  });
});

 

06.01 2017
function SubTheme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';

  $status_heading = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
    'info' => t('Informative message'),
  );

  // Map Drupal message types to their corresponding Bootstrap classes.
  // @see http://twitter.github.com/bootstrap/components.html#alerts
  $status_class = array(
    'status' => 'success',
06.01 2017
function ThemeName_form_user_login_block_alter(&$form) {
  $form['#attributes']['class'][]='form-inline';
  $form['links']['#weight'] = 100;
}
28.12 2015
function mymodule_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
  $form['quantity']['#title_display'] = 'invisible';
}
13.10 2015

Для изменения типа ноды - модуль Node convert (поддержка VBO)

Для изменения типов товара

- Views data export + feeds

- Изменение в базе через запросы вида

UPDATE commerce_product SET type = REPLACE(type, "oldtype", "newtype");

UPDATE field_data_commerce_price SET bundle = REPLACE(bundle, "oldtype", "newtype");

UPDATE field_revision_commerce_price SET bundle = REPLACE(bundle, "oldtype", "newtype");

и т.п.

 

24.08 2015

 

​$date = DateTime::createFromFormat('d/M/Y:H:i:s', $field);
return $date->format('Y-m-d H:i:s');

 

29.04 2015

Первый вариант:

1. Включить php filter

2. В настройках видимости блока задать правило:

<?php
  $url = request_uri();
  $pos = strpos($url, "page");
  if ($pos === false && arg(0) =='taxonomy' && count($_GET) == 1) {
    return TRUE;
   }
 ?>

Второй вариант:

Через модуль context, добавить 2 правила отображения блока

1. Путь

2. Query string: ~*page=*

 

21.03 2015
function theme_preprocess_node(&$variables, $hook) {
$node = $variables['node'];
if ($node->type == pd_lamp || $node->type == pd_other) {
$product = commerce_product_load($node->field_product['und']['0']['product_id']);
$price = entity_metadata_wrapper('commerce_product', $product)->commerce_price->value();;
if ($price['amount'] > 500000) {
$variables['classes_array'][] = 'new-calss';
}
//dsm($variables['classes_array']);
}
}

 

26.02 2015

Dynamic dependent fields - использование представления с динамическим аргументом для формирования списка доступных сущностный и вывода их в форме создания материала.

Reference field option limit - вывод зависимых сущностный в поле. Не работает со связью один ко многим для зависимой сущности. Позволят организовать связи вида Страна - город и т.п.

26.02 2015
function module_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#form_id'] == 'post_node_form') {    // id формы
    $top_level = taxonomy_get_tree($vid = 2, $parent = 0, $max_depth = 1); // id словаря
    foreach ($top_level as $id => $term) {
      $options[$term->name] = array();
      $children = taxonomy_get_tree(2, $term->tid); // id словаря
      foreach ($children as $child) {
        $options[$term->name][$child->tid] = $child->name;
      }
    }
    $form['field_category']['und']['#options'] = $options;
  }
}

 

Страницы