Skip to content

Instantly share code, notes, and snippets.

View amitaibu's full-sized avatar

Amitai Burstein amitaibu

View GitHub Profile
/**
* Implements hook_init().
*/
function message_example_init() {
$arguments = array(
'@view' => array(
'callback' => 'message_example_view',
'pass message' => TRUE,
)
);
@amitaibu
amitaibu / gist:5037670
Last active December 14, 2015 05:49
Print the View's query,
$query = $this->view->build_info['query'];
$output = ((string)$query);
foreach ($query->getArguments() as $key => $value) {
$output = str_replace($key, '"' . $value. '"', $output);
}
$output = str_replace(array('{', '}'), '', $output);
dpm($output);
/**
* Profile task; Attach OG related fields.
*/
function kaveret_og_setup() {
// Group type.
og_create_field(OG_GROUP_FIELD, 'node', 'project');
og_create_field(OG_ACCESS_FIELD, 'node', 'project');
// Group content type
// Enable Entity-reference prepopulate.
$og_field['instance']['settings']['behaviors']['prepopulate'] = array(
'status' => TRUE,
'action' => 'hide',
'action_on_edit' => TRUE,
'fallback' => 'redirect',
'og_context' => TRUE,
);
@amitaibu
amitaibu / gist:5213138
Created March 21, 2013 13:50
Make Views seach for LIKE
/**
* Implements hook_views_query_alter().
*/
function devel_views_query_alter(&$view, &$query) {
if (empty($query->where[1]['conditions'][1]['field'])) {
return;
}
$sub_query = $query->where[1]['conditions'][1]['field'];
if (!$conditions = &$sub_query->conditions()) {
return;
drush si -y openscholar --account-pass=admin --db-url=mysql://root:root@localhost/os --uri=http://local:8888/os openscholar_flavor_form.os_profile_flavor=development openscholar_install_type.os_profile_type=vsite
drush vset purl_base_domain http://local:8888/os
drush en -y os_migrate_demo
@amitaibu
amitaibu / devel.module
Created April 29, 2013 06:22
biblio + contributor
if (!module_exists('biblio') || !module_exists('libraries')) {
return;
}
biblio_create_field('biblio_year', 'biblio', 'book');
biblio_create_field('biblio_abstract', 'biblio', 'book');
biblio_create_field('biblio_image', 'biblio', 'book');
biblio_create_field('biblio_pages', 'biblio', 'book');
biblio_create_field('contributor_collection', 'biblio', 'book');
biblio_create_field('biblio_year', 'biblio', 'book');
biblio_create_field('biblio_abstract', 'biblio', 'book');
biblio_create_field('biblio_image', 'biblio', 'book');
biblio_create_field('biblio_pages', 'biblio', 'book');
biblio_create_field('contributor_collection', 'biblio', 'book');
biblio_create_field('biblio_contributor', 'field_collection_item', 'contributor_field_collection');
biblio_create_field('biblio_contributor_roles', 'field_collection_item', 'contributor_field_collection');
$biblio = biblio_create('book');
if (!module_exists('biblio') || !module_exists('libraries')) {
return;
}
biblio_create_field('biblio_issued', 'biblio', 'book');
biblio_create_field('biblio_abstract', 'biblio', 'book');
biblio_create_field('biblio_image', 'biblio', 'book');
biblio_create_field('biblio_pages', 'biblio', 'book');
biblio_create_field('biblio_contributor', 'biblio', 'book');
<?php
if (!module_exists('biblio') || !module_exists('libraries')) {
return;
}
biblio_create_field('biblio_issued', 'biblio', 'book');
biblio_create_field('biblio_abstract', 'biblio', 'book');
biblio_create_field('biblio_image', 'biblio', 'book');
biblio_create_field('biblio_pages', 'biblio', 'book');