Skip to content

Instantly share code, notes, and snippets.

View ccamara's full-sized avatar

Carlos Cámara ccamara

View GitHub Profile
@ccamara
ccamara / apa-esp.csl.xml
Last active October 13, 2015 16:38
American Psychological Association 6th Edition - Spanish Translation #zotero #citation-style #APA
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
<!-- This style was edited with the Visual CSL Editor (http://steveridout.com/csl/visualEditor/) -->
<info>
<title>American Psychological Association 6th Edition - Spanish Translation</title>
<id>https://gist.github.com/4225434</id>
<link href="http://www.zotero.org/styles/apa" rel="self"/>
<link href="http://owl.english.purdue.edu/owl/resource/560/01/" rel="documentation"/>
<author>
<name>Simon Kornblith</name>
@ccamara
ccamara / breadcrumb_books.php
Last active December 17, 2015 02:49
Drupal: Custom breadcrumbs for books showing hierarchy and parent's taxonomy #drupal #breadcrumbs
<?php /**
* Custom breadcrumbs for books showing hierarchy and parent's taxonomy.
*/
function feature_book_node_view($node, $view_mode, $langcode) {
if ($node->type == 'books') {
// Node is a parent.
if ($node->book['p2'] == '0') {
$wrapper = entity_metadata_wrapper('node', $node);
$themawrapper = $wrapper->field_taxonomy[0]; // Replace field_taxonomy with the propper taxonomy field.
@ccamara
ccamara / prevent_node_deletion.php
Created May 13, 2013 08:16
Prevents nodes and/or comments to be deleted. #drupal #nodes
<?php
//stop deletion of nodes and comments
function MODULE_form_alter (&$form, &$form_state) {
//stop any node/comment deletions
if ((isset($form['operation']['#value']) && $form['operation']['#value'] == 'delete') || $form['#id'] == 'node-delete-confirm' || $form['#id'] == 'comment-confirm-delete') {
//set a message...
drupal_set_message('your message');
//stop people from being able to submit the delete form (and in turn stop the delete)
unset($form['actions']['submit']);
@ccamara
ccamara / counters.scss
Created May 17, 2013 07:30
CSS Counters #css #scss
/*
* CSS Counters
* More information here: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Counters
*/
ol{
counter-reset: simple-numbering; // Sets the counter called simple-numbering to 0.
li {
list-style: none;
position: relative;
@ccamara
ccamara / drush_alias.bash
Last active December 18, 2015 00:29
Drush aliases. Copy of https://github.com/nuvoleweb/drush_alias #drush #drupal #alias
# Drush-Bash tricks 0.1
# Copyright Nuvole 2010.
# License: GPL 3, see http://www.gnu.org/licenses/gpl.html
# For a quick start: copy this entire file to the end of the .bashrc
# file in your home directory and it will be enabled at your next
# login. See http://nuvole.org/node/26 for more details and options.
# Drupal and Drush aliases.
# To be added at the end of .bashrc.
@ccamara
ccamara / gist:5772934
Last active December 18, 2015 10:59
Example of implementation of a hook validate #drupal
<?php
/**
* Implements hook_node_validate().
*
* Makes image field required.
*/
function mymodule_node_validate($node, $form, &$form_state) {
if ($node->type == 'carrousel_item') {
if (! isset($form_state['values']['field_summary_image'][LANGUAGE_NONE]['0']['entity']->field_media_summary_image[LANGUAGE_NONE][0]['fid']) ||
@ccamara
ccamara / yourmodule.module
Last active December 18, 2015 21:38
Populates an existing vocabulary with terms when a module/feature is installed #drupal #taxonomy
<?php
/**
* Implements hook_install().
*/
function yourmodule_install() {
// Populates 'name_of_vocabulary' vocabulary with taxonomy terms.
// Edit name_of_vocabulary with your desired vocabulary's machine name.
$vocabulary = taxonomy_vocabulary_machine_name_load('name_of_vocabulary');
$terms = array();
@ccamara
ccamara / module-name.module
Last active December 19, 2015 22:38
Display Suite's output modification in order to add a new class under certain circumstances #drupal #displaysuite
<?php
/**
* Implements hook_theme_registry_alter().
*/
function feature_blog_theme_registry_alter(&$theme_registry) {
$theme_registry['node']['preprocess functions'][] = 'onecolumn_class_node_preprocess';
}
/*
@ccamara
ccamara / drushrc.php
Last active December 20, 2015 13:19
Increase #drush memory limit. #drupal
<?php
/**
* Examples of valid statements for a Drush runtime config (drushrc) file.
* Use this file to cut down on typing out lengthy and repetitive command line
* options in the Drush commands you use and to avoid mistakes.
*
* Rename this file to drushrc.php and optionally copy it to one of the places
* listed below in order of precedence:
*
@ccamara
ccamara / .gitconfig
Last active May 13, 2020 20:43
#git #configuration and #aliases
[user]
name = Your Name
email = your@email.here
[color]
status = auto
branch = auto
interactive = auto
diff = auto
[alias]
st = status -sb