im working with Propel and Smarty. I have a servicios.php
file, that only contains:
include('private/autoload.php');
// Servicios Todos
$servicios = ServicioQuery::Create()->orderByTitulo(Criteria::ASC)->find()->toArray();
$smarty->assign('servicios',$servicios);
// Servicio a mostrar
$servQry = ServicioQuery::Create();
if($url->getParam(3) == '') {
$servicio = $servQry->findOneByIdservicio(1);
}else{
$servicio = $servQry->findOneBySlug($url->getParam(3));
}
// Error Line ?
$servicio = $servicio->toArray();
$smarty->assign('servicio',$servicio);
$smarty->display('templates/servicio.tpl');
The file servicio.tpl
contains:
<html>
<head>
{include file="html_head.tpl"}
</head>
<body>
....
<h2>{$servicio.Titulo}</h2>
<div class="span3">
<img class="borderFoto" src="assets/img/servicios/{$servicio.Slug}.jpg" alt="{$servicio.Slug}.jpg" />
</div>
<div class="span7">
{$servicio.Descripcion}
</div>
</body>
</html>
In the html_head.tpl
:
<title>Pilar Medicina Estética</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
So, the problem is that, the Css styles dont load. With Firebug show that instead of print the Css code, print:
Fatal error: Call to a member function toArray() on a non-object in /media/Datos/www/PilarMedicinaEstetica/owner/servicios.php on line 15
But, the error is rare, because the data is displayed correctly and the var_dump
of $servicio
dont mark errors:
array(7) { ["Idservicio"]=> int(1) ["Idsitio"]=> int(1) ["Titulo"]=> string(15) "Servicio demo 1" ["Descripcion"]=> string(979) "Nulla commodo commodo iaculis...eget pellentesque nunc nisi ac sem." ["Slug"]=> string(17) "servicio_demo_uno" ["Shares"]=> int(1) ["Activo"]=> bool(true) }
In the index.php, do the equal steps, and works. Why here not ? Any ideas ?.
The error was that i pass an wrong slug, and the query returns an empty collection jiji.