Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[1658] Implementing a template based website

Last post 06-02-2005 9:58 AM by aaron123nz. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [1658] Implementing a template based website

    This thread is for discussions of Implementing a template based website.

    • Post Points: 0
  • 10-29-2001 4:08 AM In reply to

    • outvit
    • Not Ranked
    • Joined on 10-28-2001
    • Junior Member
    • Points 80

    Question

    How well could you integrate this into ASP?

    I am working on an ASP project and would love to use something to this effect.  Could you make another tutorial on how to do this in ASP.  I am not to good at converting things to ASP quite yet, and  I have only created 3 things in ASP.

    Anything would help.
    • Post Points: 0
  • 10-29-2001 4:14 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 14,730
    • SystemAdministrator
    Conversion of VBScript ASP isn't as easy, as it doesn't currently have an equivilant of the eval statement.... using JScript in an ASP file might well let you do that (I've never used it), in which case it should be fairly easy....
    • Post Points: 0
  • 10-30-2001 5:17 AM In reply to

    • outvit
    • Not Ranked
    • Joined on 10-28-2001
    • Junior Member
    • Points 80

    More

    So is it not easy at all but sort of possible?

    I am very good with HTML, PHP, and some others, but I am just now starting ASP.  I got tired of SQL and moving on to some experimenting with ASP and OBDC.
    • Post Points: 0
  • 07-02-2002 2:01 AM In reply to

    • psn
    • Top 500 Contributor
    • Joined on 07-02-2002
    • Member
    • Points 305

    How to create a template site with MS Access 97

    I have read the article and kinda understand. But how would you create the template using MS Access 97.
    • Post Points: 0
  • 07-11-2003 4:43 PM In reply to

    • alius
    • Not Ranked
    • Joined on 07-11-2003
    • New Member
    • Points 10

    about this code

    Hi, i'd like to ask a question - why browser returns a message about undefined variable $resultbits?
    btw, there is a misunderstanding with "resultsbit" instead of "resultbit". Anyways, it's quite nice
    • Post Points: 0
  • 09-28-2003 1:41 AM In reply to

    • Defiant
    • Not Ranked
    • Joined on 09-28-2003
    • New Member
    • Points 25

    Great Information

    Just a short message to say how useful this topic was. I am currently developing a web site and found the information in this article very useful. It took a couple of tries to iron out the problems I had getting it started, but other then that, everything is working very well.

    Thanks for  the tip.

    Happy Programs
    • Post Points: 0
  • 09-29-2003 10:39 AM In reply to

    • osxboy
    • Not Ranked
    • Joined on 09-29-2003
    • New Member
    • Points 5
    Could you pass on what you did to iron out the problems?
    • Post Points: 0
  • 10-21-2003 10:38 AM In reply to

    • stw
    • Not Ranked
    • Joined on 10-21-2003
    • New Member
    • Points 5

    how to do it with an Access database

    I find this article very interesting, but I don't succeed in making it working with an MS Access database and would be glad for any help or information how to do it.

    Stephan Wölfel
    stw@freesurf.fr
    • Post Points: 0
  • 11-05-2003 11:46 PM In reply to

    • Defiant
    • Not Ranked
    • Joined on 09-28-2003
    • New Member
    • Points 25

    How I did It

    To make the template system work, the most important thing to remember is that any PHP variable you use in the template must be defined prior to calling the template. Take the template bwlow, which I use in my sites:

    <html>
    <head>
     <title>$pagetitle</title>
     <link rel="stylesheet" type="text/css" href="../css/main.css">
     <script language="JavaScript" src="../scripts/global.js" type="text/javascript"></script>  
    </head>
    <body bgcolor=#470848  topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" text=#D5D3D3>
     <table border=0 cellpadding=0 cellspacing=0 width="100%" height=100%>
      <tr height=90>
        <td width=146 align=center><img src="../images/bigbullet1.jpg" width=91 height=90></td>
        <td align=center><img src="../images/logo.gif" width="456" height="39"></td>
      </tr>
      <tr><td>
       <table background="../images/menucenter.jpg" cellpadding=0 cellspacing=0 border=0 height=100%>
        <tr><td class=bg><img src="../images/menutop.jpg"></td></tr>
        $pagemenu
        <tr><td height=99% valign=bottom><img src="../images/menubottom.jpg"></td></tr>
       </table>
      </td>
      <td valign=top>
       <center><img src="../images/line2.jpg" width=355 height=10><br>$pageheading</center><br>
       $pagecontent
      </td></tr>
     </table>
    </body>
    </html>

    The PHP variable, shown in bold face, must be defined before calling the template. Below is a typical page I would use with this template.

    <?php
    require "../php/global.inc";
    require "../php/about-menu.inc";

    $pagetitle = "About My Site";
    $pageheading="<h3>Please choose a area you would like to learn about.</h3>";
    $pagecontent = "";
    $pagemenu="";

    for ($i=0; $i < count($menunames); $i++) {
     eval("\$pagemenu .= \"".gettemplate("menu")."\";");
    }
    eval("echo \"".gettemplate("main")."\";");
    ?>

    The require statements import function unigue to my site. The point here is to show that I had to make sure that all the vairable I use in the template are defined. I also found that it works best if you give any variables you use in the templete to an empty string at the beginning of the script. It will take of some headaches later(trust me).

    I hope this helps. The example I have shown works on my system. If you have problems getting it working for your self, email me and I would be happy to help. My address is defiantapp_s@omnitelcom.com

    Happy Programming
    Defiant

    P.S. Sorry for the delay on posting a reply, been pritty busy. I will try to keep a closer eye in the future.
    • Post Points: 0
  • 11-06-2003 12:16 AM In reply to

    • Defiant
    • Not Ranked
    • Joined on 09-28-2003
    • New Member
    • Points 25
    The reason you get th error about $resultbits be undefined is because of the eval statement.

    eval("\$resultbits .= \"".gettemplate("ResultsBit")."\";");

    The operator underlined above takes to output of the gettemplate function and adds it to the $resultbits variable. However, in the script in the example does not give $resultbits a value before this eval statement, which causes the undefined error.

    To solve this probelm, simple set the $resultbits variable to an empty string at the beginning of the script usein the line  below:

    $resultbits="";

    This should solve the undefined variable error.

    As for the different spelling you mentioned, I beleive it is just a typing error.

    Hope this helps
    Happy Programming
    Defiant

    • Post Points: 0
  • 11-26-2003 12:08 AM In reply to

    • johnlcox
    • Not Ranked
    • Joined on 11-26-2003
    • New Member
    • Points 10

    Don't understand

    I'm having a really hard time understanding how this works and I am not able to test it since I don't have a mysql server setup on my computer.  Does anyone have an example they could show me that doesn't involve connecting to a database?
    • Post Points: 0
  • 02-22-2004 8:24 AM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 14,730
    • SystemAdministrator
    The article demonstrates two methods - one that uses a MySQL database to store the templates, and one that just uses a folder on the website.
    • Post Points: 0
  • 02-22-2004 8:25 AM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 14,730
    • SystemAdministrator
    The article was written before PHP had made this a requirement - I'll try and get the article updated to reflect these changes.
    • Post Points: 0
  • 02-25-2004 10:24 AM In reply to

    • jaam
    • Not Ranked
    • Joined on 02-25-2004
    • New Member
    • Points 5

    Code Errors

    This sample is great BUT have a cuople of errors.
    The file test.php is missing "#include template.php";.
    The file template.php presents a variable $name that must be repalced with $templatename.
    If you solve this all will work fine.
    • Post Points: 0
Page 1 of 2 (16 items) 1 2 Next >