PDA

View Full Version : PHP code withing templates?


limey
04-01-2003, 07:41 PM
I have a template and im pulling the page with:


<?php
error_reporting(7);

require('./global.php');


eval("dooutput(\"".gettemplate('test_temp)."\");");

?>


Now I added this bit of php in the template and its showing that code as text. I tried a few searches on php in templates and what not, but could not find it.


<?php

# Include amazon_functions
include('functions/amazon_functions.php');


# Display BrowseNodes
$BrowseNodes=amazon_browsenodes(books);
echo "<table border=0 align=left>\n";
while(list($Key,$Value)=each($BrowseNodes)) {
echo "<tr>\n";
echo "<td bgcolor='#f1f1f1' OnMouseOver=\"this.style.backgroundColor='#e1e1e1';\" OnMouseOut=\"this.style.backgroundColor='#f1f1f1';\"><a href=\"".$PHP_SELF."?BrowseNode=$Key&Mode=books\">$Value</a></td>\n";
echo "</tr>\n";
}
echo "</table><p><br>\n\n";


# Display searchform
echo amazon_create_searchform();
echo "<p><br>";



# Search results
if($SearchKeyword || $BrowseNode) {

# Perform search
if($BrowseNode)
{ $Data=amazon_browse_node($BrowseNode,$Mode); }
else
{ $Data=amazon_search($SearchKeyword,$SearchType,$Se archMode); }

# Transform searchresult-array to HTML-Table
$HTMLTable=amazon_create_productlist($Data,10,"example1_productinfo.php");

echo $HTMLTable;
}


php?>

Xenon
04-01-2003, 08:04 PM
change eval("dooutput(\"".gettemplate('test_temp)."\");");

into:
eval(gettemplate('test_temp', 0,0));
and remove the <?php ?> from the template

limey
04-01-2003, 09:14 PM
parse error: eval()'d code on line 1

limey
04-02-2003, 03:55 PM
Ok so neither of these are working....

How can I pull this code that is in a seperate file into a template with a "variable" like $amazon ?

I only need this pulled on a test template that im using with this code:


<?php
error_reporting(7);

require('./global.php');


eval("dooutput(\"".gettemplate('test_temp)."\");");

?>