page contains twice used one template

  • Hi,
    I need to create page contains more forms. Forms are nearly the same. So I created template:
    ---------- form.ihtml ---------
    <form ....
    <!-- BEGIN hiddenrow -->
    <!-- END hiddenrow -->
    <!-- BEGIN paramrow -->
    <!-- END paramrow -->
    ----------- form.ihtml ----------

    then in page I used this:
         "page" => "page.ihtml",
         "form1" => "form.ihtml",
         "form2" => "form.ihtml"));
    $t->set_block("form1", "hiddenrow", "hiddenrows");
    $t->set_block("form1", "paramrow", "paramrows");
    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");
    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

      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.