Foros del Web » Programando para Internet » PHP »

Insertar código php en .tpl

Estas en el tema de Insertar código php en .tpl en el foro de PHP en Foros del Web. Hola, Tengo un script en php el cual me gustaría insertar en el header.tpl del php weby directory y no lo consigo. He visto que ...
  #1 (permalink)  
Antiguo 15/01/2011, 04:26
 
Fecha de Ingreso: marzo-2008
Ubicación: España
Mensajes: 243
Antigüedad: 16 años, 1 mes
Puntos: 7
Insertar código php en .tpl

Hola,

Tengo un script en php el cual me gustaría insertar en el header.tpl del php weby directory y no lo consigo. He visto que se podría añadir un include (<p>{php}include("http://full path to/example.php");{/php} </p>) en tpl pero la programación no es lo mío y no sé cómo hacerlo. Además el script viene todo en el mismo archivo php.

El script es:
Código PHP:
Ver original
  1. <?php
  2. require("simplepie.inc");
  3. require("simplepie_yahoo_weather.inc");
  4.  
  5. $code = "ANXX0001";
  6. $path = "http://weather.yahooapis.com/forecastrss?u=c&p=";
  7. $feed = new SimplePie();
  8. $feed->set_feed_url($path.$code);
  9. $feed->set_item_class('SimplePie_Item_YWeather');
  10. $feed->init();
  11.  
  12. $weather = $feed->get_item(0);
  13. ?>
.....
.....
.....
Código PHP:
Ver original
  1. <table>
  2. <tr>
  3. <td><img src="<?php echo $weather->get_condition_image(); ?>" width="25" height="25" border="0" /></td>
  4. <td>Condiciones: <?php echo $weather->get_condition(); ?></td>
  5. <td>Temperatura: <?php echo $weather->get_temperature(); ?>&deg;<?php echo $weather->get_units_temp(); ?></td>
  6. <td>Humedad: <?php echo $weather->get_humidity(); ?>%</td>
  7. <td>Rising: <?php echo $weather->get_rising(); ?>%</td>
  8. <td>Amanecer: <?php echo $weather->get_sunrise(); ?></td>
  9. <td>Ocaso: <?php echo $weather->get_sunset(); ?></td>
  10. </tr></table>
.....
.....
.....

Podrían ayudarme para integrarlo en dicho header.tpl?

Gracias!

Última edición por maxtorplextor; 15/01/2011 a las 04:36
  #2 (permalink)  
Antiguo 15/01/2011, 08:03
Avatar de mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: Insertar código php en .tpl

No se de simplepie, pero por ejemplo en Smarty existe algo así {php} {/php} (si no me equivoco). Sería bueno que busques en la documentacion de simple pie.
  #3 (permalink)  
Antiguo 15/01/2011, 12:31
 
Fecha de Ingreso: marzo-2008
Ubicación: España
Mensajes: 243
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Insertar código php en .tpl

Hola voy a echarle un vistazo a Smarty...

Última edición por maxtorplextor; 15/01/2011 a las 17:51

Etiquetas: tpl
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:33.