page contains twice used one template

2002-03-07
2002-04-12
  • Vladimir Naprstek

    Hi,
    I need to create page contains more forms. Forms are nearly the same. So I created template:
    ---------- form.ihtml ---------
    <form ....
    <!-- BEGIN hiddenrow -->
    <INPUT TYPE="HIDDEN" NAME="{HNAME}" VALUE="{HVAL}">
    <!-- END hiddenrow -->
    <table>
    <!-- BEGIN paramrow -->
    <tr>
      <td>{PNME}</td>
      <td>{PITEM}</td>
    </tr>
    <!-- END paramrow -->
    </table>
    ....
    ----------- form.ihtml ----------

    then in page I used this:
    $t->set_file(array(
         "page" => "page.ihtml",
         "form1" => "form.ihtml",
         "form2" => "form.ihtml"));
    $t->set_block("form1", "hiddenrow", "hiddenrows");
    $t->set_block("form1", "paramrow", "paramrows");
    $t->set_value...
    ...
    create first form
    ...
    $t->parse("pagebody", "form1", true);

    and now I want to create second form:
    $t->set_block("form2", "hiddenrow", "hiddenrows");
    $t->set_block("form2", "paramrow", "paramrows");
    $t->set_value...
    ...
    create second form the same way as first one
    ...
    $t->parse("pagebody", "form2", true);
    ... script continues

    And result is not as I expected. First form is good, but second not. There function set_block did nothing, tags <!-- BEGIN ... -->/<!-- END ... --> remains in HTML and inside is only one row with values of last $t->set_var().

    Where is mistake (or what is good way to use one template twice in a page)?

     
    • Layne Weathers

      Layne Weathers - 2002-04-12

      Set the form file only once, then copy the contents to a new variable:

      $t->set_file(array("page" => "page.ihtml", "form1" => "form.ihtml"));
      $t->set_var("form2", $t->get_var("form1"));

      Proceed as originally.

       

Log in to post a comment.