Ejemplo para documentos: docTable


Tabla de documentos que incluye fecha, resumen, archivo (pdf), e imágen.

Ejemplo de la clase:
classes/tables.class.php
class docTable extends Table {
  function docTable() {
    $this->Table('doc');
    $this->key = 'iddoc';
    $this->title ='Documentos';
    $this->order ='iddoc ';
    $this->addColumn('iddoc','serial',0,1,0,'Id');
    $this->addColumn('doc','varchar',500,0,0,'Titulo');
    #$this->addColumn('idcategoria','int',0,0,'categoria','Categoria');
    $this->addColumn('fecha','date',0,0,0,'Fecha','-20:+1');
    $this->addColumn('resumen','text',0,0,0,'Resumen');
    $this->addColumn('portada','bool',0,0,0,'Portada?');
    $this->addColumn('archivo','file',0,0,0,'Archivo');
    $this->addColumn('imagen','image',0,0,0,'Imagen');
  }
}


Ejemplo para parte pública:
public_html/documentos.php (line 1)
  1. <?php
  2. require('../classes/app.class.php');
  3. $data = new docTable();
  4. $data->readEnv();
  5. if ($data->request['iddoc'])
  6.   $smarty->assign('row', $data->ReadRecord());
  7. else
  8.   $smarty->assign('rows',$data->ReadData());
  9. $smarty->display('documentos.tpl');
  10. ?>


Ejemplo de plantilla tpl, asumiendo tenemos un header.tpl y footer.tpl, aqui rellenamos el medio:
templates/documentos.tpl (line 1)
  1. <?php
  2. {include file="header.tpl"}
  3. {if $row}
  4.   <h1>{$row.doc}</h1>
  5.   <i>{$row.fecha}</i><br/>
  6.   <img src="/cms/pic/200/doc/{$docs[i].imagen}" alt="Portada" align="left" />
  7.   {$row.resumen|nl2br}<br/>
  8.   <img src="{$row.archivo|ficon:"doc"}"border="0"/> Descargar ({$row.archivo|fsize:"doc":"KB"})
  9. {/if}
  10. {section name=i loop=$rows}
  11.   {if $smarty.section.i.first}<h1>Documentos</h1>{/if}
  12.   <b>{$rows[i].doc</b>
  13.   {$rows[i].resumen|truncate:200}
  14.   <a href="/documentos.php?iddoc={$rows[i].iddoc}">m&aacute;s...</a><br/>
  15.   <br/>
  16. {/section}
  17. {include file="footer.tpl"}



CategoryEjemplos

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki