Skip to content

Instantly share code, notes, and snippets.

@steffenr
steffenr / node2front.php
Created September 18, 2012 06:07
redirect /node to drupal-frontpage
<?php
/**
* Implementation of hook_menu_alter().
*/
function node2front_menu_alter(&$items) {
$items['node']['page callback'] = '_node2front_redirect';
}
/**
* Redirect back to the frontpage.
@steffenr
steffenr / gist:3724109
Last active October 10, 2015 17:17
render date-field programmatically
<?php
$date_field = $node->field_date_event;
// array for configurtion
$display_settings = array (
'type' => 'date_default', // type of the date field
'settings' => array (
'format_type' => 'event' // custom date format
)
);
@steffenr
steffenr / gist:3683375
Last active October 10, 2015 11:28
update jQuery Version in Drupal 7 for specific site
<?php
function MYMODULE_js_alter(&$javascript) {
// check if we are on front_page
if(drupal_is_front_page()) {
$path = drupal_get_path('module', 'MYMODULE') . '/js/jquery-1.7.1.min.js';
// Copy the current jQuery file settings and change
$javascript[$path] = $javascript['misc/jquery.js'];
// Update necessary settings
$javascript[$path]['version'] = '1.7.1';
$javascript[$path]['data'] = $path;
@steffenr
steffenr / gist:3652225
Created September 6, 2012 06:46
create nivo_slider view
$view = new view;
$view->name = 'nivo_slider_images';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'NivoSlider';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@steffenr
steffenr / gist:3423412
Created August 22, 2012 07:27
set jquery version for specific page (Drupal 6)
<?php
function theme_preprocess_page(&$vars) {
$m_obj = menu_get_object();
if ($m_obj->type == 'product_group') {
// set jQuery 1.5.1 for slider
$path_to_slider = drupal_get_path('module', "slider");
drupal_set_html_head('<script type="text/javascript" src="'. base_path() . path_to_theme() .'/js/libs/jquery-1.5.1.min.js"></script>');
drupal_set_html_head('<script type="text/javascript" src="'. base_path() . $path_to_slider .'/ContentFlow/contentflow.js" load="ML"></script>');
drupal_add_js($path_to_slider ."/contentflow_trigger.js");
@steffenr
steffenr / gist:3132267
Created July 17, 2012 21:36
create node on webform submission
{ "rules_create_node_for_webform_data" : {
"LABEL" : "create node for webform data",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "webform_rules" ],
"ON" : [ "webform_rules_submit" ],
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "webform" : "webform" } } } }
],
"DO" : [
{ "entity_create" : {
@steffenr
steffenr / mybusinesssubtheme.info
Created July 10, 2012 05:57
extend drupal business theme to 5 slides (used subtheme)
name = Business Subtheme
description = business subtheme
version = VERSION
core = 7.x
base theme = business
regions[sidebar_first] = First Sidebar
regions[header] = Header
@steffenr
steffenr / gist:3006789
Created June 27, 2012 20:54
Rules Export - check for taxonomy term and unpublish Node
{ "rules_set_forum_content_unpublished" : {
"LABEL" : "set forum content unpublished",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "node_presave" ],
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "forum" : "forum" } } } },
{ "data_is" : { "data" : [ "node:taxonomy-forums" ], "value" : "3" } }
],
"DO" : [
@steffenr
steffenr / .htaccess
Created June 15, 2012 10:05
Drupal htaccess optimizations
# KILL THEM ETAGS
# http://www.askapache.com/htaccess/apache-speed-etags.html
FileETag none
# set expires header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|woff|eot|svg|ttf)$">
Header set Expires "Tue, 16 Jun 2020 20:00:00 GMT"
</FilesMatch>
# turn on gzip compression
@steffenr
steffenr / gist:2496728
Created April 26, 2012 06:34
wget mirror website
wget -m -k -K -e html_extension=On http://www.port11.de