Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
nucklearproject / gist:3725307
Created September 14, 2012 22:21
Pasos para crear un modulo /crud con la herramienta GII de YII framework
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:3724841
Created September 14, 2012 21:08
main.php config file YII
<?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 / .htaccess
Created September 14, 2012 21:05
.htaccess YII
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:3717801
Created September 13, 2012 21:26
Imprimir el valor de un field desde cualquier entidad de Drupal.-
/* 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);
@nucklearproject
nucklearproject / gist:3717763
Created September 13, 2012 21:21
Jquery plugin para centrar verticalmente una imagen
$.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);
});