Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Templating

Status
Not open for further replies.

YoungManRiver

IS-IT--Management
Feb 9, 2004
220
US
All,

Know this is going to sound weird to all of you, but in 1994 your's truly introduced the whole concept of templates, using .shtml with includes for the segments/sections of a page.

Well the template movement has really matured and taken off, and I'm left behind. Went out to try to get up to speed and downloaded things like:

Drupal
Smarty
Ruby
etc.

Looking at all of these I don't see anything simple and straight forward in templating. So my questions:

Am I wrong?
Did I miss the concepts somewhere?
Did I not find the right toolset?
What did I miss?

I really don't like being behind, so a little help here please!

YMR
 
In my very limited experience, Smarty seems (or seemed, several years ago) to be the favoured templating engine and does seem fairly easy to use.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
there's a blurring between templating, CMS and even blogging software. for example, i use wordpress with some custom plug-ins to act as the core of a number of my sites.

the toolsets that you have listed (plus joomla) are pretty much those that are out there. but of course straightforward templating is simplicity itself within php and no external tools are required. the include()/require() commands are all you really need.
 
jpadie,

Can always depend on you, my friend for insight. The original concept I introduced allowed for standard generic template designs, which is looking at all the tools joomla, gets the closet to, using it's modules concept, but it doesn't flow together well.

The basic concept was based on the following master template code of:

Code:
<html>
<head>
<title>My Title</title>
</head>

<body>
<table width=100% height=100% border=2 cellspacing=0 cellpadding=0 align=center valign=middle>
   <tr height=120>
   <td width=200 align=center>Logo Area</td>
   <td align=center>Title Area</td>
   <td width=200 align=center>Right IMG Area</td>
   </tr>

   <tr height=100%>
   <td align=center>L Menu Area</td>
   <td align=center>Content Area</td>
   <td align=center>Right Menu Area</td>
   </tr>

   <tr height=80>
   <td align=center>L Footer Area</td>
   <td align=center>Footer Title Area</td>
   <td align=center>Right Footer Area</td>
   </tr>
</table>

</body>
</html>
With the ability to combine any of the areas via the "colspan" & "rowspan" tags and using includes for the areas, totally define usage of any all content within the area.

Unfortunately, I think I'm seeing a loss of this concept with the sophistication of the tools and it should not be, but rather the simplicity should be the quideline, so roll-out of all other templating features are correctly defined and/or accomodated.

What is your opinion on all this?

YMR
 
Well, my first thought is that using <table> structures for layout is actively discouraged by the HTML specification, but aside from that, you absolutely can do that sort of templating in many programs. PmWiki ( is one of my preferred pieces of software, and it uses such a template structure for organizing the output. The content placeholders you have (like "Right Footer Area") are replaced by variables populated by the pmwiki.php script based on the content and permissions of each page. Plenty of other systems do the same, though I still find PmWiki much easier to work with than things like Joomla.
 
Taking a good look at Smarty, I found out that writing a template engine myself would cost way less time than trying to understand Smarty. So I did. The subversion repository (also viewable in your browser) is at:


The code directory contains the PHP code (not much at all, as a template is by no means rocket science), the SQL directory is on its way out and meant for a library that is being split off, and the testhtml directory contains the UML class diagram. The test directory contains unit tests, but they are written for use with the TinyUnit library (similar URL).

Hope it is of any help, or at least a good laugh...


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks Guys for the Feedback,

Yup, Everything I'm hearing and touching seems that templating is all over the place. Smarty, osCommerce, Zen and all them, even the .tpl gurus have no consistancy.

Your's truly is also father of the "Modular Design Concept", "Modular Methodology" and "Enterprise Modules" (
To me it's obvious I need to write a spec to get some standardization back into this whole thing for templating. I quess I'm up to the challenge and if I write the Modular Concept principles and the Enterprise Modules principles into it should be good and get some unification of direction back into this effort and also back into all the tools, etc. so the whole industry will profit.

I can also create a sourceforge site for it, but I'm currently having real issues with their CVS, not taking native commands, (but mostly CVS noobie know-how challenged), and just not getting any of my stuff into the repository or as in the case of my two existing projects with them, not putting in the right stuff and then putting in all the wrong and restricted stuff into the public folders.

So I guess I'll leave this thread open so y'all can interact with me about this and together in collaberation, we can make it work right.

YMR
 
jpadie,

the toolsets that you have listed (plus joomla) are pretty much those that are out there. but of course straightforward templating is simplicity itself within php and no external tools are required. the include()/require() commands are all you really need.
Responding to your post and thinking about this some, including some recent joomla experiences, what I'm seeing is what I call the umbrella approach instead of thinking about this is "vertical portal" or "open architecture" concepts or design.

As for the straight-forward part of PHP it's self, I tried some experiments with includes etc. and found they did not work correctly, especially when using either "include()/require()" and the file being pulled in contains vars that require substitutionary processing. I tried all the eval type functions from the PHP command set and none of them worked, which is what got me to this point, thinking "None of these system level gurus are writing in the support needed for totally open templating".

Anyway I'll post my examples somewhere and get a link in here in a few days so all of you can try to comprehend what I was experiencing.

YMR
 
All,

Code Example (dealing with only one include):
Code:
<html>
<head>
<title>My Title</title>
</head>

<body>
<table width=100% height=100% border=2 cellspacing=0 cellpadding=0 align=center valign=middle>
   <tr height=120>
   <td width=200 align=center>Logo Area</td>
   <td align=center>Title Area</td>
   <td width=200 align=center>Right IMG Area</td>
   </tr>

   <tr height=100%>
   <td align=center><?php include(men_l.php); ?></td>
   <td align=center>Content Area</td>
   <td align=center>Right Menu Area</td>
   </tr>

   <tr height=80>
   <td align=center>L Footer Area</td>
   <td align=center>Footer Title Area</td>
   <td align=center>Right Footer Area</td>
   </tr>
</table>

</body>
</html>
and the included code:
Code:
<?php
   include(db_connect.php);
   $sql = "SELECT men_id, men_url, men_des FROM menu ORDER BY men_des;";
   $result = mysql_query($sql);
   $m_list="<table width=150 align=center border=0 bgcolor=#333388 ><tr>";
   while ($row = mysql_fetch_assoc($result)) {
      $mn = $row['men_nam'];
      $mu = $row['men_url'];
      $md = $row['men_des'];
      $l_men .= "<td height=25 align=center><a href='".$mu."'>".$md."</a></td></tr>";
   }
   $l_men .= "</table>";
?>
Simple but doesn't work unless you either:
[ul]
[li]Pre-declare a class for the menu,[/li]
[li]Turn on Globals (security no-no),[/li]
[li]Push the vars into a session var,[/li]
[/ul]File could also be .tpl instead of .php result is same.

My suggestion to the PHP gurus, and maybe not a good one, cause I haven't thought about all the security impacts just yet, is to allow var processing (maybe for specific file types such as .tpl) so all the fuss over handling the vars and var evals/substitution is not needed.

What is your thoughts on this?

YMR
 
Oh sorry bout the extra row of code, having a duh moment.
Code:
$mn = $row['men_nam'];

YMR
 
would this not work
Code:
<html>
<head>
<title>My Title</title>
</head>

<body>
<table width=100% height=100% border=2 cellspacing=0 cellpadding=0 align=center valign=middle>
   <tr height=120>
   <td width=200 align=center>Logo Area</td>
   <td align=center>Title Area</td>
   <td width=200 align=center>Right IMG Area</td>
   </tr>

   <tr height=100%>
   <td align=center><?php include [red]'[/red]men_l.php[red]'[/red]; ?></td>
   <td align=center>Content Area</td>
   <td align=center>Right Menu Area</td>
   </tr>

   <tr height=80>
   <td align=center>L Footer Area</td>
   <td align=center>Footer Title Area</td>
   <td align=center>Right Footer Area</td>
   </tr>
</table>

</body>
</html>

Code:
<?php
   include(db_connect.php);
   $sql = "SELECT men_id, men_url, men_des FROM menu ORDER BY men_des;";
   $result = mysql_query($sql);
   $m_list="<table width=150 align=center border=0 bgcolor=#333388 ><tr>";
   while ($row = mysql_fetch_assoc($result)) {
      $mn = $row['men_nam'];
      $mu = $row['men_url'];
      $md = $row['men_des'];
      $l_men .= "<td height=25 align=center><a href='".$mu."'>".$md."</a></td></tr>";
   }
   $l_men .= "</table>";
   [red]echo $m_list . $l_men;
?>
[/code]

personally, i can't see why the issues you have set out could be affecting you.

class: not sure how this fits in. are you talking about an object or a css class? why would either be of importance?
globals: the include/require will operate with the scope of the line that calls it. sometimes this can be an issue, but this is the same with all coding.
session vars: this is just a way around any problems with the point above. personally i prefer to call functions or class members and pass them explicit variables.
 
All,

Sorry been away for a while so first time to get back to this.

Looking at a couple of the contributions and will get my feedback in here later.

Thanks!

YMR
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top