Jump to content

PHP fast template help


boyindie

Recommended Posts

HI

 

I am trying to build a page using the fasttemplate class.

 

I am having problems getting it to populate a drop down menu using the templating

 

I read words from a text file and I read them into array, which I loop around and set to the template

 

all i am gettin is multiple drop down boxes being printed out, with a single word in each

 

 

anyhelp would be greatly appreciated

 

cheers

boyindie

 

 

here is my html

Code: ( text )

 

  1.

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

  2.

      <html>

  3.

      <head>

  4.

      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  5.

      <title>Forum Engine</title>

  6.

      </head>

  7.

      <body>

  8.

      <div id="contentdiv">

  9.

      <table border="0" id="tblWords">

  10.

          <tr>

  11.

              <td>

  12.

     

  13.

                  {LIST}

  14.

     

  15.

              </td>

  16.

     

  17.

              <td align="center" valign="middle">

  18.

                  <image />

  19.

                  <br />

  20.

                  <image src2();"/>

  21.

              </td>

  22.

     

  23.

              <td>

  24.

              <select id="acceptWords" name="sel2" size="10" multiple="multiple"></select>

  25.

              <input type="button" value="Create Links" onClick="createLinks();">

  26.

              </td>

  27.

     

  28.

          </tr>

  29.

      </table>

  30.

     

  31.

      </div>

  32.

      </body>

  33.

      </html>

 

 

 

Code: ( text )

 

  1.

      <select id="wordlist" name="sel1" size="10" multiple="multiple">

  2.

      <option value="{OPTIONS}">{OPTIONS}</option>

  3.

      </select>

 

 

 

 

and my PHP code is as follows

 

Code: ( php )

 

  1.

      <?php

  2.

      include_once ("class.FastTemplate.php");

  3.

      class getFile

  4.

      {

  5.

     

  6.

          public function getFile()

  7.

          {

  8.

          $this->TPL= $tpl;

  9.

          }

  10.

     

  11.

     

  12.

          public function getWords()

  13.

          {

  14.

          $this->TPL = new FastTemplate("./tpl");

  15.

          $this->TPL->define(array("file_name"=>"getfile.html",

  16.

                                  "word"        =>"table_Words.tpl.html"));

  17.

          // Get URL and div

  18.

          if (!isset($_GET['file']))

  19.

              {

  20.

                  echo "File not specified.";

  21.

              }

  22.

              else

  23.

              {

  24.

                  if (!isset($_GET['url']))

  25.

                  {

  26.

                      echo "url not specified to return to";

  27.

                  }

  28.

     

  29.

                  else

  30.

                  {

  31.

                      $file =urldecode($_GET['file']);echo"<br>";

  32.

                      $url = urldecode($_GET['url']);

  33.

     

  34.

                      if (substr($url, 0, 4) != 'http')

  35.

                      {

  36.

                          // Set error

  37.

                          echo 'Invalid File - '.$file;

  38.

                          return false;

  39.

                      }

  40.

                      else

  41.

                      {

  42.

                            $text = file_get_contents($file);

  43.

                            $array = split(";",$text);

  44.

                            for($i=0; $i<=count($array);$i++)

  45.

                            {

  46.

                              $this->TPL->assign(OPTIONS,$array[$i]);

  47.

                              $this->TPL->parse("LIST",word);

  48.

                            }

  49.

                            $this->TPL->parse(PAGE,file_name);

  50.

                            $this->TPL->FastPrint(PAGE);

  51.

                      }

  52.

                  }

  53.

              }

  54.

          }

  55.

      }

  56.

      ?>

Link to comment
https://forums.phpfreaks.com/topic/90878-php-fast-template-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.