Skip to content

Instantly share code, notes, and snippets.

@aschiwi
aschiwi / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aschiwi
aschiwi / gist:5856993
Created June 25, 2013 08:51
this goes in your theme's template.php
<?php
/**
* Override variables used in page.tpl.php.
*/
function YOURTHEMENAME_preprocess_page(&$vars) {
// Adds jquery accordion library so we can use it in our site.
drupal_add_library('system', 'ui.accordion');
}
@aschiwi
aschiwi / gist:5856988
Created June 25, 2013 08:50
Contents of your node
<div id="accordion">
<h3><a href="#titel1">Deine Überschrift</a></h3>
<div>Dein aufgeklappter Text</div>
<h3><a href="#titel2">Deine zweite Überschrift</a></h3>
<div>Dein aufgeklappter Text</div>
</div>
@aschiwi
aschiwi / accordion.js
Created June 25, 2013 08:45
Put this in your theme
/**
* @file
* Use accordions in node body.
*/
(function ($) {
Drupal.behaviors.undpaulAccordion = {
attach: function(context) {
$('#accordion').accordion({
@aschiwi
aschiwi / update.sh
Last active December 18, 2015 21:39
Example update.sh
################################################################################
# Shell and drush commands to update the given installation
#
# Go to sites/all/scripts (e.g. cd sites/all/scripts) and type "sh update.sh"
# in your console/shell/Terminal.
#
# The commands have to be functional for any case after the initial installation
# installation. So on any set up after calling that script, the configuration
# must be the same.
#
@aschiwi
aschiwi / install.sh
Last active November 7, 2017 17:32
Example install.sh
################################################################################
# Shell and drush commands to set up (or some part of it) the new site.
#
# Go to sites/all/scripts (e.g. cd sites/all/scripts) and type "sh install.sh"
# in your console/shell/Terminal.
#
# The commands are built to run once, e.g. to set some symlinks, but shall be
# designed to not break other commands on the second run.
#
################################################################################
@aschiwi
aschiwi / gist:5848762
Created June 24, 2013 09:09
Example local.settings.php
<?php
// Database connection settings.
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'lokalerdatenbankname',
'username' => 'lokalerdatenbankbenutzer',
@aschiwi
aschiwi / gist:5848755
Created June 24, 2013 09:08
Include local.settings.php
<?php
/**
* Include local.settings.php
*
* The file is in .gitignore so we can safely use it for local configs.
*/
if (file_exists('sites/default/local.settings.php')) {
include('local.settings.php');
}
@aschiwi
aschiwi / gist:5780513
Last active December 18, 2015 12:09
Please check this blog post for an explanation of this code: http://www.undpaul.de/blog/2013/06/14/changing-ckeditor-skins-drupals-wysiwyg
<?php
/**
* Implements hook__wysiwyg_editor_settings_alter().
*/
function MODULENAME_wysiwyg_editor_settings_alter(&$settings, $context) {
global $base_url;
if ($context['profile']->editor == 'ckeditor') {
$skins_path = drupal_get_path('module', 'MODULENAME') . '/ckeditor/skins';
@aschiwi
aschiwi / gist:5690860
Last active December 17, 2015 23:39
How to add classes and ids to main and secondary menu in Drupal 8. Add this to your theme's .theme file (in this case it's busy.theme). The .theme file is called template.php in Drupal 7.
/**
* Implements hook_preprocess_HOOK() for page.tpl.php
*/
function busy_preprocess_page(&$variables) {
// Pass the main menu and secondary menu to the template as render arrays.
if (!empty($variables['main_menu'])) {
$variables['main_menu']['#attributes']['id'] = 'main-menu';
$variables['main_menu']['#attributes']['class'] = array('links', 'clearfix');
}
if (!empty($variables['secondary_menu'])) {