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');
}
}
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)
- <?php
- require('../classes/app.class.php');
- $data = new docTable();
- $data->readEnv();
- if ($data->request['iddoc'])
- $smarty->assign('row', $data->ReadRecord());
- else
- $smarty->assign('rows',$data->ReadData());
- $smarty->display('documentos.tpl');
- ?>
Ejemplo de plantilla tpl, asumiendo tenemos un header.tpl y footer.tpl, aqui rellenamos el medio:
templates/documentos.tpl (line 1)
- <?php
- <h1>{$row.doc}</h1>
- <i>{$row.fecha}</i><br/>
- <img src="/cms/pic/200/doc/{$docs[i].imagen}" alt="Portada" align="left" />
- {$row.resumen|nl2br}<br/>
- <img src="{$row.archivo|ficon:"doc"}"border="0"/> Descargar ({$row.archivo|fsize:"doc":"KB"})
- {/if}
- <b>{$rows[i].doc</b>
- {$rows[i].resumen|truncate:200}
- <a href="/documentos.php?iddoc={$rows[i].iddoc}">más...</a><br/>
- <br/>
- {/section}
CategoryEjemplos
There are no comments on this page. [Add comment]