[Phplib-users] Multi Tiered Templates
Brought to you by:
nhruby,
richardarcher
From: Rogers, P. <Pau...@mo...> - 2002-03-01 09:05:49
|
Dear All I have an application which uses the template system and an oracle database. (shown below). In it's current form it createsa menu based on two tables by retrieving an id based on a mnemonic for a particular menu. It then uses this to retrieve the relevent menu items and create page ie. Menu Title <-- Template Menu Item 1 <--Sub Template Menu Item 2 Menu Item 3 ....etc What I now need is to further break this menu down into sub menus ie Menu Title <-- Template SubMenu Title1 <-- Sub Template Menu Item 1 <-- Sub Sub Template Menu Item 2 SubMenu Title2 <-- Sub Template Menu Item 3 <-- Sub Sub Template ....etc I've tried amending the attached script but can't work out how to nest the three queries. I keep getting a message from Oracle stating the queries have been accessed in the wrong order. Can someone give me a simple example of how to nest three queries. I'm guessing I need a sub sub template as shown above but I can't work out how I nest all these templates/queries. Many thanks Paul <?php //webindex.php #set any default values $root = "/qa_dept/"; # This section goes and retrieves the data # common.inc includes the code for producing arrays from form fields include ('common.inc'); # Retrieve the values from the array $div = $arr_request['div'] ; $index = $arr_request['index'] ; # Define our Application Type and the vaultstem $AppType = "index" ; $VaultStem = "103" ; # create Template instance called $templ $templ = new Mowlem_Template("/usr/local/apache/htdocs/templates", "keep"); # define variables named requests and r_dbout referencing files $templ->set_file(array( "webindex" => "web".$AppType.".ihtml", "sub_webindex" => "sub_web".$AppType.".ihtml")); //Set up the query string for the map..... // We're searching for a particular Map $str_sql = " select s.id, m.str_title from mlm_web_submenu s, mlm_web_menmap m where s.parent = m.id and m.str_code = '" .$index. "' and m.str_type = '" .$AppType. "'" ; // instantiate new instance of class $db = new DB_Mowlem; // Send it the query, and get the data $db->query("$str_sql"); $db->next_record(); $Index_Id = $db->Record[id]; $Index_Title = $db->Record[str_title]; #Now we need to retreive the entries for the index $str_sql = " select mi.str_extref, mi.str_subtype, mi.str_subdoc, pg.latest, xpr.title, xpr.revn, pr.status from mlm_web_menu_items mi, xv" .$VaultStem. "_pg xpg, v" .$VaultStem. "_pg pg, xv" .$VaultStem. "_pr xpr, v" .$VaultStem. "_pr pr where mi.str_extref = xpg.extref (+) and xpg.id = pg.id (+) and pg.latest = xpr.id (+) and xpr.id = pr.id (+) and mi.parent = " .$Index_Id. "and mi.str_division like '%" .$div. "%'"; // Send the db instance our query, and get the data $db->query("$str_sql"); # extract the block named "row" from "sub_webmap", creating a # reference to {rows} in "sub_webmap". $templ->set_block("sub_webindex", "row", "rows"); while ($db->next_record()) { $doc = $db->Record[str_extref]; $DocTitle = $db->Record[title]; $subtype = $db->Record[str_subtype]; $subdoc=$db->Record[str_subdoc]; $endLink = " title=\"".$DocTitle."\" name=\"".$doc."\">".$DocTitle."</a>"; $templ->set_var(array("Reference" => $db->Record[str_extref], "Revision" => $db->Record[revn])); # Check what sort of document it is were retrieving and act accordingly switch ($subtype) { case "none": $templ->set_var(array("Doc_Title" => $DocTitle)); break; case "webpage": $templ->set_var(array("Doc_Title" => "<a href=".$root.$subdoc.$endLink)); break; case "kbank": $templ->set_var(array("Doc_Title" => "<a href=http://edmserver:2999/EDM/dosetvault?vaultname=MCE_QA_Control&destinati on=http://edmserver:2999/EDM/ftr".$endLink)); break; case "index": $templ->set_var(array("Doc_Title" => "<a href=/webindex.php?index=".$subdoc."&div=".$div.$endLink)); break; case "map": $templ->set_var(array("Doc_Title" => "<a href=/webmap.php?map=".$subdoc."&div=".$div.$endLink)); break; default: $templ->set_var(array("Doc_Title" => "<a href=/getdoc.php?vid=".$VaultStem."&prid=".$db->Record[latest].$endLink)); } # and then parse the whole lot $templ->parse("rows", "row", true); }; #This section outputs the data # define the variables PAGETITLE, NumberType, AppType & HEADER $templ->set_var(array( "Division" => $div, "Index_Title" => $Index_Title)); # build sub_mapOutput from index... $templ->parse("sub_indexOutput", "sub_webindex"); # build mapsOutput from index... $templ->parse("indexOutput", "webindex"); # finish all Output and print it. $templ->p("indexOutput"); ?> ***************************************************************************** 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. ***************************************************************************** |