开发者

Passing smarty Variables in a include ( with Codeigniter )

开发者 https://www.devze.com 2023-01-13 11:30 出处:网络
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

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">
<html xmlns="http://www.w3.org/1999/xhtml">
<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


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'
);
0

精彩评论

暂无评论...
验证码 换一张
取 消