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:5690827
Created June 1, 2013 15:56
Use this line in your Drupal 8's phptemplate theme to tell Drupal you're using the phptemplate engine.
engine: phptemplate
@aschiwi
aschiwi / gist:5690836
Created June 1, 2013 15:59
Old way to print menus in Drupal 7 page.tpl.php.
<?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'clearfix')))); ?>
@aschiwi
aschiwi / gist:5690843
Created June 1, 2013 16:00
Print your menus like this for Drupal 8 phptemplate themes.
<?php print render($main_menu); ?>
@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'])) {
@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: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: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 / 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 / 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({