Skip to content

Instantly share code, notes, and snippets.

View ccamara's full-sized avatar

Carlos Cámara ccamara

View GitHub Profile
@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 / 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 / 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>