Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
nucklearproject / gist:3717763
Created Sep 13, 2012
Jquery plugin para centrar verticalmente una imagen
View gist:3717763
$.fn.vCenter = function(){
this.each(function(){
parent_height = $(this).parent().height();
image_height = $(this).height();
top_margin = (parent_height - image_height)/2;
});
return this.each(function() {
$(this).css( 'margin-top' , top_margin);
});
@nucklearproject
nucklearproject / gist:3717801
Created Sep 13, 2012
Imprimir el valor de un field desde cualquier entidad de Drupal.-
View gist:3717801
/* Usamos directamente la API de drupal. field_get_items()
Si antes hacias esto echo $node->field_subtitle['und'][0]['value'];
Aunque funciona olvidate de volver a hacerlo!
*/
/*
Tomamos como referencia un field creado en la entidad user.
*/
$user = user_load(1);
View .htaccess
DirectoryIndex index.php
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@nucklearproject
nucklearproject / gist:3724841
Created Sep 14, 2012
main.php config file YII
View gist:3724841
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
@nucklearproject
nucklearproject / gist:3725307
Created Sep 14, 2012
Pasos para crear un modulo /crud con la herramienta GII de YII framework
View gist:3725307
1. Suponiendo que ya sabemos como manejarnos con GII, pasamos a crear un modulo:
Module Generator > Module ID * (Aca le ponemos el nombre que queramos)
2. Activamos el modulo desde nuestro main.php en este caso he creado un modulo llamado test.
'modules'=>array(
'test',
......
3. Creamos un model, suponiendo que tengo una tabla llamada testlist:
@nucklearproject
nucklearproject / gist:3725549
Created Sep 14, 2012
Usar un campo tipo ENUM como un select list en YII
View gist:3725549
/* Suponiendo que hemos creado nuestro CRUD. creamos un componente - Obviamente lo guardamos como ZHtml.php dentro de nuestra carpeta components, no hace falta inicializarlo si en nuestro main.php tenemos el autoload
'import'=>array(
'application.models.*',
'application.components.*',
),
.....
*/
<?php
View Recursively add .gitignore files to empty dirs
My .gitignore YII
#editors
*.swp
.buildpath
.project
.settings
nbproject
.idea
*.sublime-project
*sublime-workspace
@nucklearproject
nucklearproject / gist:3758096
Created Sep 20, 2012
CCK field Update with drupal_write_record()
View gist:3758096
File created in webroot.
<?php
error_reporting(E_ALL);
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
$results = db_query('select nid from node where type="store"');
@nucklearproject
nucklearproject / gist:3762249
Created Sep 21, 2012
Save and return to edit new or update node.
View gist:3762249
<?php
/**
* @file
* Replace the submit button to node creation forms that
* allows the content author to return to edit the node
*/
/**
* Implementation of hook_form_alter().
View gist:3768738
Generate makefile
FOLDER$drush generate-makefile NAMEFILE.make
Download with make files
$drush make FILE.make FOLDER
Fresh install
FOLDER$drush site-install --account-name=admin --account-pass=admin --db-url=mysql://root:PASS@localhost/DATABASE
List installed themes and modules