Skip to content

Instantly share code, notes, and snippets.

View mrconnerton's full-sized avatar

Matthew Connerton mrconnerton

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1FrZofHxVSgyJzkHtDiHBCrJBVW9Ec6VDU https://explorer.blockstack.org/address/1FrZofHxVSgyJzkHtDiHBCrJBVW9Ec6VDU
@mrconnerton
mrconnerton / bundle.php
Last active December 24, 2015 12:08
bundle parent
<?php
function CUSTOMMODULE_commerce_cart_product_add($order, $product, $quantity, $line_item) {
if (!empty($product->field_bundled_products)) {
$ids = array();
foreach($product->field_bundled_products[LANGUAGE_NONE] as $bundle) {
$ids[] = $bundle['value'];
}
$line_item->data['bundled'] = array();
$bundles = entity_load('field_collection_item', $ids);
@mrconnerton
mrconnerton / gist:5783188
Created June 14, 2013 16:13
cod create user rule
{ "rules_cod_create_user_registration" : {
"LABEL" : "cod_create_user_registration",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"TAGS" : [ "cod" ],
"REQUIRES" : [ "rules", "commerce", "registration" ],
"ON" : [ "registration_insert" ],
"IF" : [
{ "AND" : [
{ "NOT data_is_empty" : { "data" : [ "registration:anon-mail" ] } },
<?php
function mymodule_node_view($node, $view_mode, $langcode) {
if($view_mode == 'full') {
$flag = flag_get_flag('helpercontent');
if ($flag->is_flagged($node->nid)) {
drupal_goto("<front>");
}
}
}
<?php
function module_invoke() {
$args = func_get_args();
$module = $args[0];
$hook = $args[1];
unset($args[0], $args[1]);
$function = $module . '_' . $hook;
if (module_hook($module, $hook)) {
// debug here
@mrconnerton
mrconnerton / mymodule.php
Created April 29, 2012 16:07
change site name and such based on path.
<?php
function mymodule_init(){
global $conf;
if(drupal_is_front_page()){
$conf['site_name'] = "WELCOME TO THE FREAKING HOMEPAGE!";
// $conf['other_vars'] = "to change";
} else {
switch($_GET['q']){
case 'node/12345':
$conf['site_name'] = "this node is awesome!";
@mrconnerton
mrconnerton / node_field_collection_save.php
Created March 13, 2012 21:28
How to programtically save a node with field collections
<?php
// Lets just pretend your content type is "Event" with machine name "event"
$node = new stdClass();
$node->type = 'event';
node_object_prepare($node);
$node->title = "My event title";
$node->language = LANGUAGE_NONE;
@mrconnerton
mrconnerton / gist:1979037
Last active December 4, 2018 15:13
node form in ctools modal drupal 7
<?php
/*
Make Sure you include:
ctools_include('modal');
ctools_modal_add_js();
On the pages you put your link.
*/