Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin kevinquillen

View GitHub Profile
@kevinquillen
kevinquillen / gist:4235124
Created Dec 7, 2012
Adding menu names to the ul menus in Drupal 7
View gist:4235124
function themename_menu_link(&$variables) {
$element = $variables['element'];
$sub_menu = '';
$element['#attributes']['data-menu-parent'] = $element['#original_link']['menu_name'] . '-' . $element['#original_link']['depth'];
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
@kevinquillen
kevinquillen / README.md
Created Jun 2, 2013
Reddit Widget for Dashing
View README.md

Preview

Description

Took a little inspiration from the News widget to construct this Reddit widget. Simply add the subreddit .json feed URLs that you want to the top of the reddit.rb job script, and the widget will cycle through each one, showing top posts, their score, and comment count. You can also set the maxcount higher or lower, the default is 5 posts.

##Usage

@kevinquillen
kevinquillen / module.php
Last active Jul 10, 2017
Importing to a SQL table from a CSV file in Drupal, so you don't have to parse exceptionally large CSVs line by line and instead can do so with MySQL querying. This snippet assumes you have read the column headers already from the CSV and passed them as parameters, as well as the temp table name you want to use.
View module.php
<?php
/**
* Creates a temporary table to hold values from an uploaded CSV.
* @param $table_name
* @param $columns
* @param $message
* @param $context
*/
function csv_import_create_temp_table($table_name, $columns) {
@kevinquillen
kevinquillen / FeatureContext.php
Last active Jul 22, 2020
A Behat definition that will instruct the client to press a vertical tab, useful for forms leveraging Field Group in Drupal (Shiny admin theme).
View FeatureContext.php
/**
* @When I press the :vertical_tab vertical tab
* @param $vertical_tab
*/
public function iPressTheVerticalTab($vertical_tab) {
$this->getSession()->getDriver()->click('//*[contains(@class, "node-form")]/div/div[contains(@class, "vertical-tabs")]/ul/*/a/strong[text()="' . $vertical_tab . '"]');
}
@kevinquillen
kevinquillen / SearchResults.php
Created Sep 6, 2016
Example of a Controller using SearchAPI to generate a results page (without Views).
View SearchResults.php
<?php
namespace Drupal\velirsearch\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\velirsearch\Service\PagerService;
class SearchResults extends ControllerBase {
@kevinquillen
kevinquillen / PagerService.php
Created Sep 6, 2016
Example of creating a reusable object that provides the Drupal pager easily. See SearchResults.php for an example.
View PagerService.php
<?php
namespace Drupal\velirsearch\Service;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class PagerService implements ContainerAwareInterface {
@kevinquillen
kevinquillen / menu.html.twig
Created Oct 27, 2016
Applying classes and attributes to navigation under certain depth conditions
View menu.html.twig
{#
/**
* @file
* Theme override to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/kevinquillen/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="agnoster"
@kevinquillen
kevinquillen / .vimrc
Last active Jun 10, 2017
my vimrc file
View .vimrc
set nocompatible " be iMproved, required
filetype off " required
syntax enable
set number
set showcmd
set hlsearch
set incsearch
set nobackup
set noswapfile
@kevinquillen
kevinquillen / agnoster.zsh-theme
Last active Dec 21, 2016
zsh agnoster customizations
View agnoster.zsh-theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline