Skip to content

Instantly share code, notes, and snippets.

View amcgowanca's full-sized avatar

Aaron McGowan amcgowanca

View GitHub Profile
@amcgowanca
amcgowanca / MYMODULE.module.php
Created December 14, 2015 10:49
Preprocess field and replace HTTP with HTTPs for Sched.org schedules
<?php
/**
* Implements hook_preprocess_field().
*/
function HOOK_preprocess_field(&$variables) {
if ('field_FIELDNAME' == $variables['element']['#field_name'] && isset($GLOBALS['is_https']) && $GLOBALS['is_https']) {
if (!empty($variables['items'])) {
foreach (element_children($variables['items']) as $delta) {
if (!empty($variables['items'][$delta]['#markup'])) {
@amcgowanca
amcgowanca / INFO.md
Created July 1, 2015 03:41
Drupal 7 & Preferred menu links

Drupal 7 and Preferred Menu Links

One would expect that a preferred menu link item would be that link item in a menu which is the default or primary menu link item for any particular path where more than one menu link exists in the same menu with the same link path. For example, when you create a new node instance which allows for menu link creation within the node edit form, it would be expected that when the node is fully loaded (therefore contains the property menu as an array which is loaded via the invocation of hook_node_prepare that is implemented by the menu module) the $node->menu represents the preferred menu link for this node. While we can significantly rely on this method for any node's menu link when retrieved via a node object ($node->menu), we cannot expect to be the same as what may be returned from menu_link_get_preferred('node/' . $node->nid). So which is the the correct preferred menu link?

With the expectation that $node-&gt;menu represents the preferred menu link for th

@amcgowanca
amcgowanca / MODULE.module.php
Created February 28, 2015 14:07
Drupal 7: Bean view page override with bean type specific page view callback.
<?php
/**
* Implements hook_menu_alter().
*/
function MODULE_menu_alter(&$items) {
if (isset($items['block/%bean_delta'])) {
$items['block/%bean_delta']['page callback'] = 'MODULE_bean_view_page';
}
}
@amcgowanca
amcgowanca / MODULE.module.php
Last active August 29, 2015 14:16
Drupal 7: Restrict available options for View Mode field when creating new for Bean instances
<?php
/**
* @file
*/
/**
* Implements hook_form_FORM_ID_alter().
*
* Retrieves the view mode information for the Bean type and makes available
* as an option only those view modes which apply to this Bean by having
@amcgowanca
amcgowanca / MY_MODULE.module
Created February 19, 2015 18:19
Drupal 7: Path argument mapping to $form_state['values'] default
<?php
/**
* Retrieves a single form by the $form_id and maps path arguments to values.
*
* This function mimics the behaviour of drupal_get_form() however it also
* provides a mechanism to map path arguments to the default values provided
* to the form via $form_state['values']. This solves a massive problem with
* the Drupal core ability to correctly handle forms with that have methods of
* type "GET" (<form method="get">) correctly.
@amcgowanca
amcgowanca / patch.patch
Created February 19, 2015 01:36
Drupal 7: Patch for panelizer for menu links "disappearing"
diff --git a/plugins/entity/PanelizerEntityNode.class.php b/plugins/entity/PanelizerEntityNode.class.php
index 5ea50a1..14027ce 100644
--- a/plugins/entity/PanelizerEntityNode.class.php
+++ b/plugins/entity/PanelizerEntityNode.class.php
@@ -32,6 +32,9 @@ class PanelizerEntityNode extends PanelizerEntityDefault {
if (isset($entity->workbench_moderation)) {
$entity->workbench_moderation['updating_live_revision'] = TRUE;
}
+ if (!empty($entity->menu['link_title'])) {
+ $entity->menu['enabled'] = TRUE;

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
<?php
/**
* Returns the node identifier should the path be a node viewing path.
*
* Note: This function returns FALSE for all node action or local task paths
* such as node/[nid]/edit.
*
* Furthermore, a node alias may be specified as $path which will perform a path
* normalization allowing for the node system path to be retrieved and parsed.
*
@amcgowanca
amcgowanca / github-pull-request-template.md
Last active August 18, 2016 21:53
Pull Request Template

Ready State: Yes|No

This pull request is related to the following JIRA tickets: XYZ-1: Sample Ticket A.

Requirements & Dependencies

  • This new module requires version xyz of module.
  • Requires pull request #148.

Deployment Instructions

@amcgowanca
amcgowanca / MODULENAME.install
Last active August 29, 2015 14:03
Views Argument Cache with Indexing: Update argument index table `aid` length
<?php
/**
* @file
*/
/**
* Implements hook_schema_alter().
*/
function MODULENAME_schema_alter(&$schema) {
if (isset($schema['views_arg_cache_index_arguments'])) {