Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Implements hook_menu()
*/
function hoverslider_menu(){
$items = array();
$items['admin/config/content/hoverslider'] = array(
'title' => 'Hover slider settings page',
'description' => 'This settings page is to set how many rows you want, images to each box etc...',
@Greg-Boggs
Greg-Boggs / gist:7379255
Last active December 27, 2015 19:48 — forked from anonymous/gist:7379243
Select all Journal Entries written by user 1
SELECT *
FROM node node
LEFT JOIN users users_node
ON node.uid = users_node.uid
LEFT JOIN field_data_body field_data_body
ON node.nid = field_data_body.entity_id
AND (field_data_body.entity_type = 'node'
AND field_data_body.deleted = '0')
LEFT JOIN field_data_field_image field_data_field_image
ON node.nid = field_data_field_image.entity_id
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
<?php
function web2theme_preprocess_user_profile(&$variables) {
if( arg(2)==null ) { //im not editing
$qty_field=count($variables['user_profile']['field_telefone']['#items']);
for($i=0 ; $i<$qty_field; $i++) {
$field_collection_id = $variables['field_telefone'][$i]['value'];
//dsm($variables['user_profile']['field_telefone'][$i]['entity']['field_collection_item'][$field_collection_id]['field_telefone_showed']);
$toshow = $variables['user_profile']['field_telefone'][$i]['entity']['field_collection_item'][$field_collection_id]['field_telefone_showed'];
#!/bin/bash
# Script to install Drupal app
# Be careful using database credentials, this script is meant to be used on development server, to speed things up.
dbuser="root"
dbpass="root"
sites_path="~/Sites"
if [ $# -lt 1 ];
@Greg-Boggs
Greg-Boggs / template.php
Last active August 29, 2015 14:09 — forked from anonymous/gist:eda2facf47642acc2446
Alter a campaign monitor form to include honey pot.
<?php
function tng_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'campaignmonitor-subscribe-form') {
honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
}
}
@Greg-Boggs
Greg-Boggs / config-dev.patch
Last active August 29, 2015 14:10 — forked from sun/config-dev.patch
This patch for Drupal 8 will enable the much anticipated CMI Config in Code... I think.
diff --git a/sites/default/settings.php b/sites/default/settings.php
index b2ce930..9d0514e 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -611,7 +611,8 @@
* The 'bootstrap_config_storage' setting needs to be a callable that returns
* core.services.yml.
*/
- # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
+$settings['bootstrap_config_storage'] = 'Drupal\Core\Config\BootstrapConfigStorageFactory::getFileStorage';
diff --git a/sites/default/settings.php b/sites/default/settings.php
index b2ce930..9d0514e 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -611,7 +611,8 @@
* The 'bootstrap_config_storage' setting needs to be a callable that returns
* core.services.yml.
*/
- # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
+$settings['bootstrap_config_storage'] = 'Drupal\Core\Config\BootstrapConfigStorageFactory::getFileStorage';
@Greg-Boggs
Greg-Boggs / Php56 install homebrew mac drupal
Last active April 13, 2018 20:47 — forked from nrackleff/drupal-56-upgrade
Install Php56 with Drupal configs on Mac with Homebrew with xedebug and OPcache
Steps to update local dev environment to PHP5.6 to be ready for Drupal 8.
In a terminal window:
brew update ( you may also may need brew doctor)
brew unlink php55
brew install php56 --with-homebrew-apxs --with-apache
brew install php56-xdebug
<?php
// Inside form alter function insert validation using buttons like commerce does.
// Insert the validation at the beginning of the array so the commerce module
// can access any of our errors and place them in the correct block instead of at top of page.
array_unshift($form['buttons']['continue']['#validate'], 'treepeople_commerce2_organization_validate');
// Inside the validate function, set the errors using a special concatenated field name
// that include the panel the field is in. Notice there are no outer brackets.
form_set_error('customer_profile_billing][field_organization_name', t('Company/Organization Name field is required.'));