Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Caracteres raros en include

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish
View previous topic :: View next topic  
Author Message
gatopanah
Smarty n00b


Joined: 21 Apr 2010
Posts: 3

PostPosted: Thu Apr 22, 2010 5:02 pm    Post subject: Caracteres raros en include Reply with quote

Hola a todos, he creado mi plantilla y todo lo que muestro en el {$contenido} se hace correctamente:

motor.php
------------
Code:
$smarty->assign('contenido',$smarty->fetch("$tpl"));
$smarty->display("$tpl_tipo");


plantilla
---------
Code:
{$contenido}



Mi problema ocurre al utilizar bloques, lo hago con includes tal que asi:

Code:
<div id="bloqueizq">
         {include file="/lateral.php"}   
</div> <!-- Bloque izquierda -->
{$contenido}


Pero no me muestra bien tildes, la "ñ",etc.. de cualquier include que añada.

¿A qué es debido? .. ¿Como cargais vosotros bloques dentro de la plantilla? ¿Con include?

Gracias.
Back to top
View user's profile Send private message
Davod
Smarty Rookie


Joined: 29 Sep 2009
Posts: 21

PostPosted: Tue Apr 27, 2010 5:46 pm    Post subject: Reply with quote

A simple vista parace un porblema de Smarty, pero mirándolo bien, es un problema de Charset en la página de salida. Probablemente la página esté escrita en "ISO-8859-1" mientras que el Carset en la página es "UTF-8"
Code:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

Primero, Valida pa la página usando el Validador de la W3C.

Algunas sugerencias sobre Smarty:

En lugar de hacer un $fetch y asignarlo a $assign, usa {fetch} en la misma Plantilla. Para esto, asigna un Nombre de Plantilla en lugar de obtener su contenido. esto es particularmente útil si estamos usando Caching.

Script:
Code:
$smarty->assign('contenido',$tpl); // $tpl es el Nombre de la Plantilla
$smarty->display("$tpl_tipo");
Template:
Code:
{fetch file=$contenido} {* Usar fetch para obtener el contenido *}
Back to top
View user's profile Send private message
gatopanah
Smarty n00b


Joined: 21 Apr 2010
Posts: 3

PostPosted: Wed Apr 28, 2010 2:40 pm    Post subject: Reply with quote

El charset es el mismo en todas las urls .. pero

He comprobado que si el archivo esta en /templates/*.
Code:

{include file="archivo.php"}
---->
Me imprimte todos los caracteres correctamente.


Sin embargo esto si el archivo esta en subcarpeta /templates/subcarpeta/*.
Code:

{include file="subcarpeta/archivo.php"}
--->
Me imprime caracteres raros .. acentos, eñes, etc....



Davod, ¿sabes a que se debe? Gracias compañero.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP