[Phplib-users] Multiple Blocks in Templates (using the same template form)
Brought to you by:
nhruby,
richardarcher
From: Rogers, P. <Pau...@mo...> - 2002-01-09 14:10:39
|
Dear All I have a a php template script (see below). It references two templates, newuser.ihtml and select_dbout.ihtml (see below). What I am trying to do is use select_dbout.ihtml twice within new user.ihtml to give database driven select lists. It all works fine until I have both $templ->parse("rows", "row", true); statements when I get the following error message: Template Error: loadfile: row is not a valid handle. Halted. Can anyone explain why this and if it is possible to use the block template witihin the same file? Many thanks Paul <?php //newuser.php include("common.inc"); // requires include_path to be functioning global $PHP_SELF; // instantiate new instance of DB class $db = new DB_Mowlem; # Define our Application Type $AppType = "newuser"; # create Template instance called $templ $templ = new Mowlem_Template("/usr/local/apache/htdocs/templates", "keep"); # define variables named newuser and select_dbout referencing files $templ->set_file(array( "$AppType" => $AppType.".ihtml", "select_dbout" => "select_dbout.ihtml")); // ROLES FIELD //Set up the query string...... $str_sql = " select id, name from roles" ; // Send the DB Object the query $db->query("$str_sql"); # extract the block named "row" from "select_dbout", creating a # reference to {rows} in "select_dbout". $templ->set_block("select_dbout", "row", "rows"); while ($db->next_record()) { $templ->set_var(array("key" => $db->Record[id], "name" => $db->Record[name])); }; # build status_dbOutput from index... $templ->parse("roles_dbOutput", "select_dbout"); // STATUS FIELD //Set up the query string...... $str_sql = " select value, name from user_status" ; // Send the DB Object the query $db->query("$str_sql"); # extract the block named "row" from "select_dbout", creating a # reference to {rows} in "select_dbout". $templ->set_block("select_dbout", "row", "rows"); while ($db->next_record()) { $templ->set_var(array("key" => $db->Record[value], "name" => $db->Record[name])); $templ->parse("rows", "row", true); }; # build menuOutput from index... $templ->parse("newuserOutput", "newuser"); # finish all Output and print it. $templ->p("newuserOutput"); ?> ----- template newuser.ihtml ------- <HTML> <HEAD> <TITLE>mowlem</TITLE> <STYLE TYPE="text/css"> <!-- @import url(../styles/mowlem1.css); --> </STYLE> </HEAD> <body> <div class="Header"> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca b#version=5,0,0,0" width="100%" height=144 > <PARAM NAME=movie VALUE="../flash/mowlem.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> </OBJECT> </div> <div class="Navigation"> </div> <div class="Content"> <p><h3><b>Create A New User</b></h3></p> <form method="POST" action="./None"> <input type="hidden" name="user_id" value="{user_id}"> <table> <p> <tr> <td> User Name: <input type="text" name="user_uname"> </td> <td> <tr> <td> Status: <select name="user_status"> {status_dbOutput} </select> </td> <td> Role: <select name="user_role"> {roles_dbOutput} </select> </td> </tr> </table> ----- template select_dbout.ihtml ----- <!-- start dbout.ihtml --> <!-- BEGIN row --> <OPTION VALUE="{key}">{name}</OPTION> <!-- END row --> <!-- end dbout.ihtml --> ***************************************************************************** This email and any attachments transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person. It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the Company. ***************************************************************************** |