Jump to content

Need help with HTML_Template_IT


whats_her_name

Recommended Posts

So I'm just starting out with PHP, and would like to use templates.  I keep reading how easy HTML_Template_IT is, but it just won't work for me, and I'm getting SO FRUSTRATED!

 

Please let me know if you see anything wrong with this code - because I just can't seem to find it, no matter what I change.  It's posted here:  http://www.tickled-ink.ca/shopping/shopping.php

 

What should be displayed is a list of 1 (currently that's all that's in the db) store.  When I don't use a template, I get exactly the output I want - change to the template & I get a big, fat blank screen...

 

Directory structure:

./

./web

./web/includes

./web/includes/php

./web/includes/templates

./web/shopping/

 

LET ME KNOW IF YOU NEED ANYTHING ELSE!!  THANKS FOR YOUR HELP!

Karrie

 

This is the PHP file shopping.php (NOTE:  custom functions are all in db.php)

<?php
   include "HTML/Template/IT.php";
   include "../includes/php/db.php";

   if (!($connection = @ mysql_connect($hostname, $username, $password)))
      die("Cannot connect to database.  Try again later.");
   if (!(@ mysql_select_db($databaseName, $connection)))
      showerror();

   $shoppingQuery = getShoppingQuery();
   if (!($result = mysql_query($shoppingQuery, $connection))) {
      showerror();
   } else {
      $tpl = new HTML_Template_IT("../includes/templates/");
      $tpl->loadTemplatefile("shopping.tpl.htm", true, true);

      // HEADER SECTION
      $headerString = getHeaderString();
      $tpl->setCurrentBlock("PHEADER");
      $tpl->setVariable("VHEADER", $headerString);
      $tpl->parseCurrentBlock();

      //SECTION TITLE
      $tpl->setCurrentBlock("PTITLE");
      $tpl->setVariable("PAGETITLE", "Shopping in Regina's Warehouse District");
      $tpl->parseCurrentBlock();
   
      //BUSINESSES SECTION
      while ($row = mysql_fetch_array($result)) 
      {
         $addressString = getAddressString($row["suite_number"], $row["building_address1"]);
  
         $tpl->setCurrentBlock("BUSINESSES");
         $tpl->setVariable("ID", $row["business_id"]);
         $tpl->setVariable("BUSINESS", $row["business_name"]);
         $tpl->setVariable("ADDRESS", $addressString);
         $tpl->setVariable("PHONE", $row["phone_numbr"]);   
         $tpl->parseCurrentBlock();
      }
   
      //FOOTER SECTION
      $footerString = getFooterString();

      $tpl->setCurrentBlock("PFOOTER");
      $tpl->setVariable("VFOOTER", $footerString);
      $tpl->parseCurrentBlock();

      $tpl->show();
   }
?>

 

This is the template file that is saved in ../includes/templates/shopping.tpl.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html401/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>The Warehouse District - Shopping & Services</title>

<script language="JavaScript">
   function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
         document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
   }

   MM_reloadPage(true);
</script>

<link rel="stylesheet" href="../styles.css" type="text/css">

</head>
<body bgcolor="#000099" background="../../images/back-1.jpg" link="0" vlink="0" alink="0">

<script type='text/javascript' src='../rowda_1.js'></script>
<script type='text/javascript' src='../menu_com.js'></script>
<noscript>Your browser does not support script</noscript>

<div id="container">
<!-- BEGIN PHEADER -->
{VHEADER}
<!-- END PHEADER -->

<div id="content" style="height:400px;"><img src="../../images/arc_content.jpg" width="733" height="76">
   <div style="float:left; padding: 0px 10px 10px 30px; width:150px;">
      <h1>Shopping & Services</h1>
   </div>
   <div style="float:left; padding: 0px 0px 0px 0px; width:480px;">
      <!-- BEGIN PTITLE -->
  <h3>{PAGETITLE}</h3>
  <!-- END PTITLE -->
      <table width="480" border="0" cellspacing="0" cellpadding="0">
     <tr>
	    <td width="150" align="left">Business Name</td>
		<td width="200" align="left">Address</td>
		<td width="130" align="left">Phone</td>
	 </tr>
         <!-- BEGIN BUSINESSES -->
	 <tr>
	    <td width="150" align="left"><a href="businessInfo.php?id={ID}">{BUSINESS}</a></td>
		<td width="200" align="left">{ADDRESS}</td>
		<td width="130" align="left">{PHONE}</td>
	 </tr>
	 <!-- END BUSINESSES -->
  </table>
   </div>
</div>
<div id="footer_contact"></div>
<div id="clear"></div>
<!-- BEGIN PFOOTER -->
{VFOOTER}
<!-- END PFOOTER -->
</div>
</body>
</html>

 

THANKS AGAIN!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.