Connecting Tech Pros Worldwide Forums | Help | Site Map

fasttemplate with drop down box

Newbie
 
Join Date: Jun 2007
Posts: 24
#1: Feb 12 '08
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
Expand|Select|Wrap|Line Numbers
  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>
Expand|Select|Wrap|Line Numbers
  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

[PHP]<?php
include_once ("class.FastTemplate.php");
class getFile
{

public function getFile()
{
$this->TPL= $tpl;
}


public function getWords()
{
$this->TPL = new FastTemplate("./tpl");
$this->TPL->define(array("file_name"=>"getfile.html",
"word" =>"table_Words.tpl.html"));
// Get URL and div
if (!isset($_GET['file']))
{
echo "File not specified.";
}
else
{
if (!isset($_GET['url']))
{
echo "url not specified to return to";
}

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

if (substr($url, 0, 4) != 'http')
{
// Set error
echo 'Invalid File - '.$file;
return false;
}
else
{
$text = file_get_contents($file);
$array = split(";",$text);
for($i=0; $i<=count($array);$i++)
{
$this->TPL->assign(OPTIONS,$array[$i]);
$this->TPL->parse("LIST",word);
}
$this->TPL->parse(PAGE,file_name);
$this->TPL->FastPrint(PAGE);
}
}
}
}
}
?>[/PHP]

dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#2: Aug 1 '08

re: fasttemplate with drop down box


HOW 'BOUT SMARTY ?

You're using a oblique class written by some fella that is not so popular.

At times like this, If you can't ask the guy who wrote it, you're out of luck.

Smarty, however, has an incredible manual and many people are familiar with it.

Let us know what you decide,



Dan
Reply