syntax: returning php code from an external function
Posted: Wed Sep 01, 2004 8:15 pm
feyd | Please use
And the last piece of code is the function itself which is in my functions file
I am getting an error with the engine telling me that using the "$t" variable within the display function is invalid, which I understand because it has not been declared within the scope of that function. Now my question is how to I get this function to return code to that will then parse the information to the template file. I am sure it is a syntax issue, but since I am a newbie I ask your indulgence.
Best,
Ed.
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
K, another syntax question. I am trying to use a function to return php in order that will in turn replace variables within a template.
The following is the code I am using to set up the template fileCode: Select all
$t->set_file(array("PAGE" => "roundtablesThread.tpl"));
$t->set_block("PAGE", "THREADS_ROW", "BROWSE_OUTPUT");
$t->set_block("PAGE", "AH_ROW", "AH_OUTPUT");
//bellow is the call to the function, in same page as the template setup
thread_display ($_REQUEST['cid'], 0, $moderator);Code: Select all
function thread_display($global, $parent, $moderator)
{
$sql = "SELECT title, thread_id, author, date FROM roundtable_text WHERE (category_id='".$global."' AND parent_id='".$parent."') ORDER BY date DESC";
$result = mysql_query($sql)
or diet("Could not select discussion thread from DB");
while ($row = mysql_fetch_array($result))
{
display($row['title'], $row['author'], $row['date'], $moderator, $global, $row['thread_id']);
if($row['child_id'] == 1)
{
thread_display($global, $row['thread_id'], $moderator);
}
}
return;
}
function display($title, $author, $date, $moderator, $global, $disp_thread)
{
if($moderator)
{
$t->set_var(array("TITLE" => $title));
$t->set_var(array("AUTHOR" => $author));
$t->set_var(array("DATE" => $date));
$t->set_var(array("TRASH" => "<a href=discussionDelete.php?cid=".$global."&tid=".$disp_thread."> <img height =11px src=http://www.vicouncil.org/templates/images/business/trash.gif border=0> </a>"));
$t->parse("BROWSE_OUTPUT", "THREADS_ROW", true);
}
else
{
$t->set_var(array("TITLE" => $title));
$t->set_var(array("AUTHOR" => $author));
$t->set_var(array("DATE" => $date));
$t->parse("BROWSE_OUTPUT", "THREADS_ROW", true);
}
return;
}Best,
Ed.
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]