Skip to content

Instantly share code, notes, and snippets.

@druman
druman / radiobutton.css
Created January 11, 2018 13:38
Nice radiobuttons
/****** RADIO *******/
@keyframes click-wave {
0% {
height: 30px;
width: 30px;
opacity: 0.35;
position: relative;
}
100% {
height: 200px;
@druman
druman / new-settings.php
Created January 11, 2018 13:37
Shortcut - create more then 7 items. In settings.php added
$conf['shortcut_max_slots'] = 10;
@druman
druman / prog-create-drupal-commerce-order.php
Created November 17, 2017 13:30 — forked from wluisi/prog-create-drupal-commerce-order.php
Programmatically Create Drupal Commerce Order
<?php
/**
* Creates an order for the given user containing the product with the given id.
* This example may be extended easily to create an order containing several
* products, a shipping and so far.
*
* Returns a commerce order that's now saved in the database with the status
* "processing and can be finished by an administrator in the UI.
* Throws an exception, if something is wrong.
@druman
druman / carousel.js
Created June 15, 2017 11:09
Vertical slick slider (carousel)
@druman
druman / sklonenie.js
Created June 8, 2017 07:56
Склонение на js
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
declOfNum(count, ['отзыв', 'отзыва', 'отзывов']);
@druman
druman / template.php
Created May 22, 2017 05:28
Remove CDATA js in Drupal 7
function mytheme_js_alter(&$js){
unset($js['settings']);
}
@druman
druman / MY_CUSTOM_MODULE.module
Created May 22, 2017 05:24
Get display node id for a commerce product
/**
* Get display node id for a commerce product.
* @param $product_id
* An integer value of the product id.
* @param string $product_field_name
* Name of the commerce_product_reference field used to reference products from display node.
* @return FALSE|node_id
* Returns FALSE if no results or display node id on success.
*/
function MY_CUSTOM_MODULE_get_display_node_by_product_id($product_id, $product_field_name = 'product_reference') {
@druman
druman / myjspass.module
Created May 19, 2017 13:17
Hide & collapsed items exposed filters with pass vars to JS
<?
/**
* Impliment hook_menu().
*/
function myjspass_menu() {
$items = array();
// Configuration Page
$items['admin/config/myjspass'] = array(
@druman
druman / my_module.module
Created April 1, 2017 12:35
Duplicate comerce variations product in views. Need content:nid field!
/**
* Implements hook_views_pre_execute().
*
* Rewrite SQL query to prevent duplicates based on NID
*/
function my_module_views_pre_execute(&$view) {
if ($view->name == '') {
$query = $view->build_info['query'];
$count_query = $view->build_info['count_query'];
$query->groupBy('nid');
@druman
druman / template.php
Created March 27, 2017 14:20
Change src pictures on data-src in field
function themename_preprocess_field(&$variables, $hook) {
$element = &$variables['element'];
if ($element['#entity_type'] == 'NAME'){
foreach ($variables['items'] as $key => $val) {
$output = $val['#markup'];
$delta = str_replace('src', 'data-src', $output);
};
$variables['items'] = array(