Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/08/2010, 12:22
Avatar de pateketrueke
pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años, 1 mes
Puntos: 2534
Respuesta: Cargar contenido estilo wordpress

el concepto es sencillo, aunque nada o poco elegante si usamos muchas globales... sin embargo a mi también me agrada el estilo, aunque no es la única forma...

se trata de tener un arreglo con todos los registros a iterar de manera coherente, podemos hacerlo a traves de globales, funciones con variables internas estáticas u OOP, patrón Registry, etc...

aquí un breve ejemplo:
Código PHP:
class Registry {
  protected static 
$data;
  public static function 
set_value($key$row)
  {
    
self::$data[$key] = $row;
  }
  public static function 
get_value($key)
  {
    return 
self::$data[$key];
  }
}

function 
have_users()
{
  static 
$set = array(
    
=> array('nick' => 'foo'),
    
=> array('nick' => 'candy'),
    
=> array('nick' => 'nothing'),
  );
  if (
$old array_shift($set)) return set_user($old);
  return 
FALSE;
}

function 
set_user($set)
{
  
Registry::set_value('item'$set);
  return 
TRUE;
}

function 
the_nick()
{
  
$old Registry::get_value('item');
  return 
$old['nick'];
}

while (
have_users())
{
  echo 
'<p>Nick: ' the_nick() . '</p>';

en si, las variantes pueden ser muchas, depende de tu propia forma de implementarlo....

aún así el concepto no difiere mucho, espero te sirva de algo..
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.