Skip to content

Instantly share code, notes, and snippets.

View bricel's full-sized avatar

Brice Lenfant bricel

View GitHub Profile
@bricel
bricel / gist:4104295
Created November 18, 2012 08:50
Embed view
$view = views_get_view('questions');
$view->set_arguments(array($topic_node->nid));
$output = $view->preview('panel_pane_1');
if (!empty($view->result)) {
// We don't need to show anything.
return;
}
@bricel
bricel / gist:4222444
Created December 6, 2012 07:20
Bubble grey background gradient
background: rgb(245,245,245); /* Old browsers */
background: -moz-linear-gradient(left, rgba(245,245,245,1) 0%, rgba(242,242,242,1) 60%, rgba(236,236,236,1) 73%, rgba(233,233,233,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(245,245,245,1)), color-stop(60%,rgba(242,242,242,1)), color-stop(73%,rgba(236,236,236,1)), color-stop(100%,rgba(233,233,233,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(245,245,245,1) 0%,rgba(242,242,242,1) 60%,rgba(236,236,236,1) 73%,rgba(233,233,233,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(245,245,245,1) 0%,rgba(242,242,242,1) 60%,rgba(236,236,236,1) 73%,rgba(233,233,233,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(245,245,245,1) 0%,rgba(242,242,242,1) 60%,rgba(236,236,236,1) 73%,rgba(233,233,233,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(245,245,245,1) 0%,rgba(242,242,242,1) 60%,rgba(236,236,236,1) 73%,rgba(233,2
@bricel
bricel / findcreateterm.php
Created December 11, 2012 07:30
Find and create term
// Find term.
$term_origin = taxonomy_get_term_by_name($origin_name);
// Create term.
$term = new stdClass();
$term->name = $category_name;
$term->vid = $product_category_vid;
taxonomy_term_save($term);
// Contextual links wigget. TODO: make this custom to creative page.
div.contextual-links-wrapper {
ul.contextual-links {
width: 100px;
right: auto;
top: 18px;
}
function aaa($race = 'humans') {
$terms = taxonomy_get_term_by_name($race, 'race');
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'video')
->propertyCondition('status', NODE_PUBLISHED)
->fieldCondition(field_video_link, 'entity_id', null, '<>')
->fieldCondition(field_blog_race, 'entity_id', $race)
->propertyOrderBy('created', 'DESC');
->range(0, 1);
/** Controler
* @param $auction
* @return mixed
*/
public function getHighestMailBidderAmount($auction) {
return $auction->bids_mail[0];
}
/**
@bricel
bricel / gist:5170f0e3f8b1a7552ce2
Created June 18, 2014 06:17
Pantheon apache solr API settings
# Pantheon Apache Solr settings.
drush --strict=0 @blau.dev en pantheon_apachesolr -y
drush --strict=0 @blau.dev vset pantheon_apachesolr_schema "profiles/blau/modules/contrib/apachesolr/solr-conf/solr-4.x/schema.xml"
function bootstrap_subtheme_preprocess_button(&$vars) {
$vars['element']['#attributes']['class'][] = 'btn';
if (isset($vars['element']['#value'])) {
if ($class = _bootstrap_colorize_button($vars['element']['#value'])) {
$vars['element']['#attributes']['class'][] = $class;
}
}
}
$query
->entityCondition('entity_type', 'node')
->range(0,1)
->propertyOrderBy('updated', DESC);
$result = $query->execute();
if (empty($result['node'])) {
return time("10.10.2014");
}
// Find the designer node.
$conditions = array(
'title_field' => array('type' => 'field', 'value' => $row->designer_heb),
);
if ($designer_nid = $this->createNode('designer', $conditions, $values)) {
$wrapper->field_designer->set($designer_nid);
}