views:

31

answers:

1

Hello, I'm very newbie to php and codeigniter (and smarty too).

I follow a lot of tutorials and Now I'm confident with my smarty + CodeIgniter configuration, but now I have this escenario. I want to pass a couple of variables into a smarty include in order to show just two strings in the include ( the header, the strings are part of the title )

This is the include (header.tpl):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$Titulo} - {$NombreModulo} - Some Static text.com</title>
<link rel="stylesheet" type="text/css" media="screen" href="/sitio/contenido/css/Style.css" />
{literal}
<script type="text/javascript" src="/sitio/contenido/js/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" charset="utf-8">
{/literal}
(some code omitted)

and my controller:

function index()
{
    //$this->load->view('welcome_message');
    $this->load->library('smarty_parser');
    $datos = array (
    'texto' => 'String de prueba',
    'elapsed_time',1500,
    'TituloPagina','Inicio',
    'Modulo','Dashboard'
    );
    $this->smarty_parser->parse('plantilla.tpl', $datos);
}

and the file Plantilla.tpl (the template)

{include file="head.tpl" Titulo=$TituloPagina NombreModulo=$Modulo }
<div id="cuerpo">
{include file="sidebars/dashboard.tpl"}
</div>
<div id="contenido"> {$texto} </div>
<!-- fin del contenido -->

</div>
<div id="footer"> </div>
</body></html>

The problem here is the first line on the last file (or a least I think so). I can put a static string here ({include file="head.tpl" Titulo="Static Title" NombreModulo="Another one"} ) and it works, but doesn't work with the way the documentation says.

Clarifying, what I want to accomplish is to send some string variables to the smarty include to be printed on the tittle tags, from the controller.

UPDATE The code, when is set up like this, just display - - Some Static text.com

+3  A: 

Well, this part is incorrect:

$datos = array (
'texto' => 'String de prueba',
'elapsed_time',1500,
'TituloPagina','Inicio',
'Modulo','Dashboard'
);

Should be:

$datos = array (
'texto' => 'String de prueba',
'elapsed_time' => 1500,
'TituloPagina' => 'Inicio',
'Modulo' => 'Dashboard'
);
captaintokyo
thanks. It's hard to admit but this is a very rookie mistake. I had my eyes above the smarty code and I never think the error was in the php code. Thanks, it's working now
josecortesp
You're welcome... these kind of things are easily overlooked.
captaintokyo