Ahora el problema que me surgio es que necesito añadirle una funcion que despliegue los resultados de un query, estuve mirando algunas otras (Fasttemplate y la de Nok) como para ver si podia hacerlo pero por ahora escapa a mis posibilidades
![Negando](http://static.forosdelweb.com/fdwtheme/images/smilies/negar.gif)
Necesitaria si es posible que me den algunas ideas sobre esto
![Pensando](http://static.forosdelweb.com/fdwtheme/images/smilies/scratchchin.gif)
Muchas gracias de antemano
![de acuerdo](http://static.forosdelweb.com/fdwtheme/images/smilies/dedosarriba.png)
Les pasteo el codigo del template:
Código PHP:
class EasyTemplate
{
// Public variable ---------------------------------------------------------
var $error = ""; // Last error message will be stored here
// Private variables -------------------------------------------------------
var $tags = array(); // The tag values pairs, as defined by assign()
var $template_file = ""; // The template file
/*
* void EasyTemplate(string template_file)
* Constructor - assign template_file to the class
*/
function EasyTemplate($template_file)
{
// Basic check whether the template file exists or not,
// unfortunately, we can't return(false) in a constructor
if(!file_exists($template_file))
{
$this->error = "The template file $template_file does not exist.";
}
// Assign template file
$this->template_file = $template_file;
}
/*
* bool assign(string tag, string value)
* Assign a value for template tag
* Sets $this->error and returns false on error, returns true on success
*/
function assign($tag, $value)
{
// If the supplied tag name is empty, bail out
if(empty($tag))
{
$this->error = "Tag name is empty";
return(false);
}
// Assign value to tag
$this->tags[$tag] = $value;
return(true);
}
/*
* mixed easy_parse()
* Return the parsed template as string
* Sets $this->error and returns false on error, or returns the parsed template on success
*/
function easy_parse()
{
// Read in template file, suppress error messages
$contents = @implode("", (@file($this->template_file)));
// Loop through all assigned tag-value pairs
while(list($key, $value) = each($this->tags))
{
// Construct the template tag name
$tag = '{'.$key.'}';
// Is there such a tag in the template?
if(!strstr($contents, $tag))
{
$this->error = "Tag $tag not found in template ".$this->template_file.".";
return(false);
}
// Replace the template tag with the respective value
$contents = str_replace($tag, $value, $contents);
}
// Return the parsed template
return($contents);
}
/*
* bool easy_print()
* Parse and print the current template
* Sets $this->error and returns false on error, returns true on success
*/
function easy_print()
{
// Parse the template
$ret = $this->easy_parse();
// Error found?
if($ret == false)
{
return(false);
}
// Output the parsed template
print($ret);
return(true);
}
}
function parse($ReturnVar, $FileTags)
{
$append = false;
$this->LAST = $ReturnVar;
$this->HANDLE[$ReturnVar] = 1;
if (gettype($FileTags) == "array")
{
unset($this->$ReturnVar); // Clear any previous data
while ( list ( $key , $val ) = each ( $FileTags ) )
{
if ( (!isset($this->$val)) || (empty($this->$val)) )
{
$this->LOADED["$val"] = 1;
if(isset($this->DYNAMIC["$val"]))
{
$this->parse_dynamic($val,$ReturnVar);
}
else
{
$fileName = $this->FILELIST["$val"];
$this->$val = $this->get_template($fileName);
}
}
// Array context implies overwrite
$this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS);
// For recursive calls.
$this->assign( array( $ReturnVar => $this->$ReturnVar ) );
}
} // end if FileTags is array()
else
{
// FileTags is not an array
$val = $FileTags;
if( (substr($val,0,1)) == '.' )
{
// Append this template to a previous ReturnVar
$append = true;
$val = substr($val,1);
}
if ( (!isset($this->$val)) || (empty($this->$val)) )
{
$this->LOADED["$val"] = 1;
if(isset($this->DYNAMIC["$val"]))
{
$this->parse_dynamic($val,$ReturnVar);
}
else
{
$fileName = $this->FILELIST["$val"];
$this->$val = $this->get_template($fileName);
}
}
if($append)
{
$this->$ReturnVar .= $this->parse_template($this->$val,$this->PARSEVARS);
}
else
{
$this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS);
}
// For recursive calls.
$this->assign(array( $ReturnVar => $this->$ReturnVar) );
}
return;
} // End parse()