Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesus Manuel Olivas jmolivas

View GitHub Profile
@jmolivas
jmolivas / gist:1373785
Last active Sep 28, 2015
Agregar taxonomy term id como clase en el elemento body al visualizar nodo completo
View gist:1373785
<?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 Apr 12, 2012
ManyToMany - Undefined index
View gist:2369209
-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 Oct 9, 2012
Left panel with twitter bootstrap
View gist:3862120
/* css */
.modal.fade.in {
display:block;
top: 0;
right: 0;
position: fixed;
bottom: 0;
left: auto;
max-height: none;
@jmolivas
jmolivas / gist:3954344
Created Oct 25, 2012
Twig template code - Displaying flash messages using bootstrap
View gist:3954344
{# 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 Oct 26, 2012
Twig - $app/console generate:doctrine:crud on #Symfony 2.1
View gist:3959750
<!-- 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 Oct 26, 2012
Controller - $app/console generate:doctrine:crud on #Symfony 2.1
View gist:3959754
/**
* 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 Nov 15, 2012
PHP Goutte BWT reader
View draft 1
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 Oct 13, 2015
Twitter Bootstrap resources
View 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 Dec 10, 2015
git + gitflow alias
View .gitconfig
[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 Jan 29, 2013
drupal computed field entity export
View computed field
$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',