Skip to content

Instantly share code, notes, and snippets.

View amitaibu's full-sized avatar

Amitai Burstein amitaibu

View GitHub Profile
<?php
$field = field_info_field(OG_GROUP_FIELD);
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
db_insert($table_name);
$dummy_form_state = $form_state;
if (empty($form_state['rebuild'])) {
// Form is "fresh" (i.e. not call from field_add_more_submit()), so
// re-set the items-count, to show the correct amount for the mocked
// instance.
$dummy_form_state['field'][$field_name][LANGUAGE_NONE]['items_count'] = !empty($dummy_entity->{$field_name}[LANGUAGE_NONE]) ? count($dummy_entity->{$field_name}[LANGUAGE_NONE]) : 0;
}
@amitaibu
amitaibu / gist:5687354
Created May 31, 2013 19:25
Map jekyll to ER
foreach (field_info_instances('node', 'post') as $field_name => $instance) {
if (empty($instance['settings']['jekyll_map'])) {
continue;
}
// The Jekyll variable name.
$jekyll = $instance['settings']['jekyll_map'];
$field = field_info_field($field_name);
switch ($field['type']) {
# Create an application in github https://github.com/settings/applications/new
# And add it to your install.sh
# Set github connect
drush vset github_connect_client_id "XXX"
drush vset github_connect_client_secret "XXX"
@amitaibu
amitaibu / gist:5794822
Last active December 18, 2015 14:09
Angular http service.
angular.module("appName")
.factory("productService", function() {
var cache = $cacheFactory("productService");
return {
gettingProducts: function(id){
var defer = $q.defer();
var product = store.get(id);
if (!product){
---
title: Black
field_product_color_image:
- /products/galina/black/images/black.jpg
entity_id: 'commerce_product:1'
field_product:
- 'commerce_product:1'
- 'commerce_product:2'
layout: product_page
field_images:
<?php
$style_name = 'bibtex';
ctools_include('plugins');
$plugin = biblio_get_biblio_style($style_name);
$class = ctools_plugin_load_class('biblio', 'biblio_style', $style_name, 'class');
$biblio_style = new $class($plugin);
$data = '
Drupal.Nodejs.socket.on('message', function(data) {
console.log(data);
});
<?php
/**
* Gets the path of system-appropriate temporary directory.
*/
function file_directory_temp() {
$temporary_directory = variable_get('file_temporary_path', NULL);
if (empty($temporary_directory)) {
$directories = array();
@amitaibu
amitaibu / article.php
Last active December 19, 2015 21:19
Auto term create.
<?php
$this
->addFieldMapping('field_category', 'field_category')
->separator('|')
->arguments(array('create_term' => TRUE));