Skip to content

Instantly share code, notes, and snippets.

View wesruv's full-sized avatar
🤔
Why can I have a status?

wesruv wesruv

🤔
Why can I have a status?
View GitHub Profile
@eugene-ilyin
eugene-ilyin / render_menu.php
Last active October 26, 2017 23:47
Render menu programmatically in Drupal 7
// One level menu.
$menu = menu_tree('main-menu');
$menu_items = render($menu);
// Menu with many levels.
menu_tree_all_data('main-menu');
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));
@jibran
jibran / .eslintrc
Last active July 19, 2017 12:14
Sample eslint file for Drupal 7
{
"env": {
"browser": true
},
"globals": {
"Drupal": true,
"jQuery": true,
"tinyMCE": true
},
"rules": {
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@jdillick
jdillick / generate-strongarms.php
Last active August 29, 2015 13:56
Drush script to generate strongarm variables module for a site
<?php
$args = drush_get_arguments();
if ( ! isset($args[2]) ) {
drush_set_error('Usage: drush @<alias> scr generate-strongarm.php <module_name> <base_path>');
exit();
}
$module_name = $args[2];
if ( ! isset($args[3]) ) {
@jdillick
jdillick / aliases.drushrc.php
Last active December 24, 2015 02:39
Dynamic drush aliases. Just modify $paths to include the directory to your drupal installs, and you have instant aliases.
<?php
// the current environment
$env = $_ENV['ENVTYPE'] ? $_ENV['ENVTYPE'] : '';
// paths to search for drupal sites
$paths = array(
'/var/www/multisites/',
'/var/www/schoolyard/',
);
@naxoc
naxoc / pre-commit
Created November 26, 2012 21:05
Drupal git commit hook
#!/usr/bin/php
<?php
/**
* @file
* This is a Git pre-commit hook that informs you when you are
* about to commit whitespace or a debug function.
*/
$red = "\033[1;31m";
$red_end = "\033[0m";
@JustAdam
JustAdam / drupal_taxonomy_content_type.php
Created August 2, 2012 09:49
Drupal 7 - Programmatically create a taxonomy and attach a field to it, then create a content type and attach that taxonomy to it.
<?php
// Machine name for our custom node
define('NODE_NAME', 'the_node_machine_name');
// Machine name for our custom taxonomy
define('TAXONOMY_NAME', 'the_taxonomy_machine_name');
function module_install() {
_create_taxonomy();
_create_content_type();
}
@trongthanh
trongthanh / gist:2779392
Last active March 27, 2024 04:50
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.