[eluser]Tanque[/eluser]
hey, this is the first post i put in the forum... i hope u like it... let me explain it...
first, here is the controller i created... note that i didn't work with models when i think about it... the true is i didn't know about them up to that day... i hope you like it...
the array with the navbar it's load it in the index... it's a multidimensional array... first the name of the controller i would load... then, just the name of the buttom (to load it in the code)... section => buttom name...
Code:
<?php
class Informes extends Controller
{
function __construct()
{
parent::Controller();
$this->load->helper(array('text', 'date', 'fechas'));
$this->load->library('parser');
}
function index()
{
$this->db->from('informes');
$this->db->orderby('id', 'desc');
$query = $this->db->get();
$data['secciones'] = array(
anchor('inicio', 'Inicio'),
anchor('servicios', 'Servicios'),
anchor('clientes', 'Clientes'),
anchor('staff', 'Staff'),
anchor('informes', 'Informes'),
anchor('contactos', 'Contactos'));
$data['attributes'] = array('id' => 'nav');
$data['navegacion'] = ul($data['secciones'], $data['attributes']);
$data['subtitulo'] = 'Consultores en Finanzas';
$data['title'] = 'Maxinver - Consultores en Finanzas';
$data['seccion'] = 'Informes';
$data['contacto'] = 'Teléfono 4328 9455 - [email protected]';
$data['logo'] = img('images/logo.jpg');
$data['base_url'] = $this->config->item('base_url');
$data['informes'] = $query->result_array();
$this->parser->parse('informes', $data);
}
function descargar($id)
{
$this->load->helper('download');
$this->db->select('id, titulo, fecha');
$this->db->from('informes');
$this->db->where('id', $id);
$query = $this->db->get();
$row = $query->row();
// Read the file's contents
$data = file_get_contents($this->config->item('base_url') . 'uploads/' . $row->id . '.pdf');
$name = $row->titulo . '.pdf';
force_download($name, $data);
redirect('/informes/', 'refresh');
}
}
?>
using the parse function of the template library, i put each variable in the right place...
Code:
<html>
<head>
<link rel='stylesheet' type='text/css' media='all' href="{base_url}/default.css" />
<title>{title}</title>
</head>
<body>
<div id="wrap">
<div id="page">
<div id="header">
{navegacion}
</div>
<div id="content-primary">
{logo}
<h1>{subtitulo}</h1>
<h3>{seccion}</h3>
{informes}
<h4><a href='{base_url}index.php/informes/descargar/{id}'>{fecha} - {titulo}</a></h4>
<p class="descripcion">{resumen}</p>
{/informes}
</div>
<div id="footer">
<p>{contacto}</p>
</div>
</div>
</div>
</body>
</html>
i hope you like it... and, if you wanna, u can test it in
www.eltanqueargentino.com/index.php/informes ... at least, i love what i've done...
do you like it?...