Skip to content

Instantly share code, notes, and snippets.

@jmolivas
jmolivas / gist:1373785
Last active September 28, 2015 02:58
Agregar taxonomy term id como clase en el elemento body al visualizar nodo completo
<?php
function NOMBRE_DEL_TEMA_alpha_preprocess_html(&$variables) {
if ( isset($variables) ) {
if(arg(0)=='node' && is_numeric(arg(1))) {
$node = menu_get_object();
if ( isset( $node->field_section['und'][0]['tid'] ) )
$taxonomy_term = $node->field_section['und'][0]['tid'];
if ( isset( $node->field_section['es'][0]['tid'] ) )
$taxonomy_term = $node->field_section['es'][0]['tid'];
if ( isset($taxonomy_term) )
@jmolivas
jmolivas / gist:2369209
Created April 12, 2012 17:08
ManyToMany - Undefined index
-User entity:
/**
* Owning Side
*
* @ORM\ManyToMany(targetEntity="Company\MyBundle\Entity\Team", inversedBy="users")
* @ORM\JoinTable(name="user_team",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="team_id", referencedColumnName="id")}
* )
@jmolivas
jmolivas / gist:3862120
Created October 9, 2012 23:24
Left panel with twitter bootstrap
/* css */
.modal.fade.in {
display:block;
top: 0;
right: 0;
position: fixed;
bottom: 0;
left: auto;
max-height: none;
@jmolivas
jmolivas / gist:3954344
Created October 25, 2012 18:00
Twig template code - Displaying flash messages using bootstrap
{# twig template #}
<div class="flash-messages">
{% block flashes %}
{% for notice_level in ['success','error','info', 'warning', 'notice'] %}
{% if app.session.hasFlash(notice_level) %}
<div class="alert alert-{{ notice_level }}">
<a class="close" data-dismiss="alert" href="#">x</a>
<h4 class="alert-heading">{{ notice_level }}</h4>
{{ app.session.flash(notice_level) }}
@jmolivas
jmolivas / gist:3959750
Created October 26, 2012 16:28
Twig - $app/console generate:doctrine:crud on #Symfony 2.1
<!-- edit.html.twig -->
<form action="{{ path('project_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }}>
<input type="hidden" name="_method" value="PUT" />
{{ form_widget(edit_form) }}
<p>
<button type="submit" class="btn btn-primary">Edit</button>
</p>
</form>
@jmolivas
jmolivas / gist:3959754
Created October 26, 2012 16:29
Controller - $app/console generate:doctrine:crud on #Symfony 2.1
/**
* Edits an existing Project entity.
*
* @Route("/{id}", name="project_update")
* @Method("PUT")
* @Template("ProjectBundle:Project:edit.html.twig")
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
@jmolivas
jmolivas / draft 1
Created November 15, 2012 21:20
PHP Goutte BWT reader
header('Content-Type: text/xml');
require_once __DIR__.'/../goutte.phar';
include __DIR__."/../include/FeedTypes.php";
use Goutte\Client;
$client = new Client();
$crawler = $client->request('GET', 'http://apps.cbp.gov/bwt/');
$locations = array ( "CalexicoEast", "CalexicoWest" );
@jmolivas
jmolivas / Twitter Bootstrap resources
Last active October 13, 2015 08:57
Twitter Bootstrap resources
-Official page
http://twitter.github.com/bootstrap/
-Plugins/Addons
--DatePicker
https://github.com/eternicode/bootstrap-datepicker
--TimePicker
https://github.com/jdewit/bootstrap-timepicker
--ColorPicker
http://www.eyecon.ro/bootstrap-colorpicker/
@jmolivas
jmolivas / .gitconfig
Last active December 10, 2015 16:08
git + gitflow alias
[alias]
hist = log --graph --pretty=format:'%C(yellow)%h%Creset -%C(green)%d%Creset %s %C(cyan)(%cr) %C(magenta)<%an>%Creset' --abbrev-commit --date=relative
ff = flow feature
ffs = flow feature start
ffc = flow feature checkout
fff = flow feature finish -r
st = status
ci = commit
br = branch
co = checkout
@jmolivas
jmolivas / computed field
Created January 29, 2013 08:25
drupal computed field entity export
$data = array(
'bundles' => array(
'article' => (object) array(
'type' => 'article',
'name' => 'Article',
'base' => 'node_content',
'module' => 'node',
'description' => 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.',
'help' => '',
'has_title' => '1',