Skip to content

Instantly share code, notes, and snippets.

View krystianbuczak's full-sized avatar

Krystian Buczak krystianbuczak

View GitHub Profile
@krystianbuczak
krystianbuczak / remove-drupal-aliases-with-empty-source.php
Created February 10, 2017 07:08
Simple Drupal 7 script that removes aliases with empty source.
// Use this simple script in empty aliases sitaution, when you have many rows
// in "url_alias" table with "source" column being empty.
$query = db_select('url_alias', 'ua')->fields('ua');
$query->condition('ua.source', '', '=');
//$query->range(0, 500); // uncomment if plan to do this job in smaller chunks
$paths = $query->execute()->fetchAll();
foreach($paths as $object) {
if (is_numeric($object->pid)) {
path_delete($object->pid);
@krystianbuczak
krystianbuczak / Pimp My Log: Drupal syslog regex configuration
Created November 18, 2015 16:47
Drupal syslog regex configuration for Pimp My Log php log viewer
// paste it in your config.user.php configuration file in section files: {}
"syslog": {
"display" : "Drupal",
"path" : "\/var\/log\/drupal.log", //set your Drupal syslog file path
"refresh" : 5,
"max" : 10,
"notify" : true,
"order" : -1,//set order you want
"sort" : "Date",
"thinit" : [ "Date", "Site", "Type", "Request", "Referer", "UID", "Message" ],
@krystianbuczak
krystianbuczak / ctools_modal_example.php
Last active August 29, 2015 14:15
Use ctools modal to display content in special modal
<?php
/**
* @file Custom modal using ctools modal window
* more infor in sites/modules/ctools/help/modal.html your local drupal's installation
*/
/**
* Implements of hook_menu()
*/
function custom_popup_menu() {
@krystianbuczak
krystianbuczak / drupal_theme_image_style
Created February 9, 2015 14:30
Generate image style in Drupal
theme('image_style', array(
'style_name' => 'machine_name_of_image_style',
'path' => $file->uri,
'alt' => 'Alternative name atribute',
'title' => 'Title atribute'
)
);
@krystianbuczak
krystianbuczak / gist:2ab37ac18872584ec056
Created January 27, 2015 11:43
Embed drupal webform
// get contact webform
$node = node_load(xx);
$submission = (object) array();
$enabled = TRUE;
$preview = FALSE;
$contact_form = drupal_get_form('webform_client_form_xx', $node, $submission, $enabled, $preview);
@krystianbuczak
krystianbuczak / vertical-align
Created November 29, 2014 23:07
How to align elements vertically
/**
* Remeber to set child element at least to
* display: inline-block;
* vertical-align: middle;
* More info and credits: http://css-tricks.com/centering-in-the-unknown/
*/
%ghostValign(){
&:before {
content: '';
display: inline-block;