Skip to content

Instantly share code, notes, and snippets.

View m7v's full-sized avatar
🇯🇵
私はノボシビルスクのエンジニアです

Andrew Mikhailov m7v

🇯🇵
私はノボシビルスクのエンジニアです
View GitHub Profile
@m7v
m7v / Hook_css_alter
Created November 29, 2013 04:09
Hook_css_alter
/**
* Implements hook_css_alter().
*/
function wd_site_css_alter(&$css) {
$exclude = array(
'modules/aggregator/aggregator.css' => FALSE,
'modules/block/block.css' => FALSE,
'modules/book/book.css' => FALSE,
'modules/comment/comment.css' => FALSE,
'modules/dblog/dblog.css' => FALSE,
@m7v
m7v / Promocode_entitty.php
Last active August 29, 2015 13:57
Create your Entity
/**
* Implements hook_schema().
*/
function spaint_promocode_schema() {
$schema['spaint_promocode'] = array(
// example (partial) specification for table "node"
'description' => t('The base table for nodes.'),
'fields' => array(
'id' => array(
'description' => t('The primary identifier for a node.'),
@m7v
m7v / spaint_cache.module
Created March 28, 2014 00:54
Hook_cron
/**
* Implements hook_cron().
*/
function spaint_cache_cron() {
// Set interval for run cron. Default value is 1 day.
$interval = variable_get('spaint_cache_cron_interval', 86400);
if (time() >= variable_get('spaint_cache_cron_next_execution', 0)) {
spaint_cache_set_data_about_user_tracks();
watchdog('success', t('Cache set for user\'s count tracks is successful'));
spaint_cache_set_data_about_user_votes();
@m7v
m7v / spaint_cache.module
Created March 28, 2014 00:55
Hook_js (provided module JS)
/**
* Implements hook_js().
*/
function spaint_cache_js() {
$items = array();
require_once DRUPAL_ROOT . '/includes/path.inc';
$items['user_data'] = array(
'callback' => 'user_data',
@m7v
m7v / spaint_cache.drush.inc
Created March 28, 2014 00:56
Create Drush command
function spaint_cache_drush_command() {
$items = array();
$items['spaint-cache-update'] = array(
'description' => dt('Update cache data about tracks and user information'),
);
return $items;
}
@m7v
m7v / spaint_iframe.module
Created March 28, 2014 00:58
Create access plugin
/**
* Implements hook_ctools_plugin_directory().
*/
function spaint_iframe_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' || $module == 'panels' || $module == 'page_manager') {
return 'plugins/' . $plugin;
}
// Safety: go away if CTools is not at an appropriate version.
if (!module_invoke('ctools', 'api_version', VUD_REQUIRED_CTOOLS_API)) {
return;
@m7v
m7v / page404.inc
Created March 28, 2014 01:01
Create page404/403 like Ctools CT plugin
<?php
/**
* Callback function to supply a list of content types.
*/
function spaint_track_page404_ctools_content_types() {
return array(
'single' => TRUE,
'title' => t('page404'),
'description' => t('page404 CTools CT'),
'category' => t('spaint_track'),
@m7v
m7v / changelog.inc
Created March 28, 2014 01:03
Views takes $_GET. {Hack} //Creating Ctools plugin that is retrieve views result by GET-parameters.
<?php
/**
* Callback function to supply a list of content types.
*/
function spaint_site_changelog_ctools_content_types() {
return array(
'single' => TRUE,
'title' => t('Changelog'),
'description' => t('Changelog CTools CT'),
@m7v
m7v / template.php
Created March 28, 2014 01:05
Define your own preprocesses and templates for nodes.
function spaint_preprocess_node(&$variables, $hook) {
global $theme;
global $language;
$variables['node']->field_image[LANGUAGE_NONE][0]['title'] = $variables['title_field'][$language->language][0]['value'];
// Initialize templates architecture.
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
@m7v
m7v / template.php
Created March 28, 2014 01:06
Create <a> with GET in URL
$variables['title_image_small'] = l(
$title,
$url_track,
array(
'attributes' => array(
'title' => $title,
'rel' => 'title-gallery',
'class' => array(
'spaint-title-image',
'spaint-gallery'