phplib-users Mailing List for PHPLIB (Page 93)
Brought to you by:
nhruby,
richardarcher
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(106) |
Sep
(99) |
Oct
(44) |
Nov
(97) |
Dec
(60) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(56) |
Feb
(81) |
Mar
(134) |
Apr
(69) |
May
(106) |
Jun
(122) |
Jul
(98) |
Aug
(52) |
Sep
(184) |
Oct
(219) |
Nov
(102) |
Dec
(106) |
2003 |
Jan
(88) |
Feb
(37) |
Mar
(46) |
Apr
(51) |
May
(30) |
Jun
(17) |
Jul
(45) |
Aug
(19) |
Sep
(5) |
Oct
(4) |
Nov
(12) |
Dec
(7) |
2004 |
Jan
(11) |
Feb
(7) |
Mar
|
Apr
(15) |
May
(17) |
Jun
(13) |
Jul
(5) |
Aug
|
Sep
(8) |
Oct
(6) |
Nov
(21) |
Dec
(13) |
2005 |
Jan
(4) |
Feb
(3) |
Mar
(7) |
Apr
(7) |
May
|
Jun
(11) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
2006 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(5) |
2007 |
Jan
(15) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(9) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
|
Jun
(3) |
Jul
(1) |
Aug
(19) |
Sep
(2) |
Oct
|
Nov
|
Dec
(6) |
2009 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
From: Richard A. <rh...@ju...> - 2001-08-16 12:39:07
|
At 10:58 AM +0200 16/8/01, Guenther Theilen wrote: >I'm using the challenge_auth class to avoid sending passwords in clear >if the browser supports Javascript. >Now this seems not to work with the IE on the Mac. >Everything else seems to work (I tested Win, Linux and Mac-NN) >Is this a known bug? Yup. Doesn't work for me either. I've been working on the md5 stuff recently. Give these files a try and let me know how they go. Note that I only have a Mac, so I'd appreciate it if people could try them on different platforms! http://mel01.juggernaut.com.au/phplib/crcloginform.ihtml http://mel01.juggernaut.com.au/phplib/new_user_md5.txt There are multiple bugs in new_user_md5 fixed, and the crcloginform works well for me in Netscape 4.7, Explorer 4.5, Explorer 5.0 and Mozilla. ...Richard. |
From: Guenther T. <th...@eq...> - 2001-08-16 08:58:17
|
Hi, I'm using the challenge_auth class to avoid sending passwords in clear if the browser supports Javascript. Now this seems not to work with the IE on the Mac. Everything else seems to work (I tested Win, Linux and Mac-NN) Is this a known bug? Guenther |
From: Peter B. <re...@f2...> - 2001-08-16 08:14:17
|
At 05:48 PM 8/16/01 +1000, you wrote: > >I thought that this SQL was specific to MySQL :-( > >You're right... at least it won't work on MSSql/ODBC: > >Warning: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server] >Could not find stored procedure 'show'., SQL state 37000 in >SQLExecDirect in D:\www\test\html\test.php on line 24 > >Bummer! > >I guess you just have to perform the query and see if you encounter >an error. I tried that, but I couldn't suppress an error message :-( Actually I found that changing var $Halt_On_Error in db_mysql.inc to "no" cured the problem - however, this variable isn't implemented in the other database drivers, and I only have access to MySQL so cannot test it on the other databases at the present time :-( Can you confirm how the other drivers react if there is no table present? Thanks, Peter. -- In the beginning was the word, and the word was Content-type: text/plain. |
From: Richard A. <rh...@ju...> - 2001-08-16 07:53:49
|
At 8:21 AM +0100 16/8/01, Peter Bowyer wrote: >I thought that this SQL was specific to MySQL :-( You're right... at least it won't work on MSSql/ODBC: Warning: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server] Could not find stored procedure 'show'., SQL state 37000 in SQLExecDirect in D:\www\test\html\test.php on line 24 Bummer! I guess you just have to perform the query and see if you encounter an error. ...R. |
From: Peter B. <re...@f2...> - 2001-08-16 07:34:13
|
At 07:12 AM 8/16/01 +1000, you wrote: >You'll get back a result set like: > >mysql> show tables; >+-----------------------+ >| Tables_in_j0_phplib | >+-----------------------+ >| active_sessions | >| active_sessions_split | >| auth_user | >| auth_user_md5 | >| db_sequence | >+-----------------------+ >5 rows in set (0.00 sec) > > >Just loop through the results looking for your table. I thought that this SQL was specific to MySQL :-( *** Note to list admin: can we please set the reply-to header to point back to the list? Thanks! *** Thanks, Peter. > --oOo-- Narrow Gauge on the web - photos, directory and forums! http://www.narrow-gauge.co.uk --oOo-- Peter's web page - Scottish narrow gauge in 009 http://members.aol.com/reywob/ --oOo-- |
From: Richard A. <rh...@ju...> - 2001-08-16 06:02:18
|
At 12:01 PM +0700 16/8/01, Abu Hudzaefah wrote: >I saw there is no special variabel to select value, using template >(IF), example: > >{TMPL_IF VAR=1} > do 1 >{TMPL_ELSE} > do 2 >{/TMPL_IF} > >how to do it on template class? You should place all your application logic in your PHP script. Here's an example that was posted to the old list. ...Richard. :::::::::::::: conditionaltest1.tmpl :::::::::::::: <HTML> <BODY> {IMG} </BODY> </HTML> :::::::::::::: conditionaltest2.tmpl :::::::::::::: <!-- BEGIN img_block --> img src="images/{IMAGE}" {IMGSIZE}<br> <!-- END img_block --> <!-- BEGIN swf_block --> swf src="images/{IMAGE}" {IMGSIZE}<br> <!-- END swf_block --> :::::::::::::: conditionaltest.php :::::::::::::: <?php include("template.inc"); $testdata = array("image1.gif", "movie2.swf", "movie3.swf", "image4.jpg"); $t = new Template(".","comment"); $t->debug=0; # load the page from conditionaltest1.tmpl into "page" # load image tag from conditionaltest2.tmpl into "img_tags" $t->set_file(array("page" => "conditionaltest1.tmpl", "img_tags" => "conditionaltest2.tmpl")); # extract from "img_tags" the block named "img_block", leaving a # reference to {img_block_tag} $t->set_block("img_tags", "img_block", "img_block_tag"); # extract from "img_tags" the block named "swf_block", leaving a # reference to {swf_block_tag} $t->set_block("img_tags", "swf_block", "swf_block_tag"); # loop through our test data for ($cc = 0; $cc < count($testdata) ; $cc++) { # set variables with substitution data $t->set_var("IMAGE", $testdata[$cc]); $t->set_var("IMGSIZE", "size"); if (ereg("\.swf$", $testdata[$cc])) { $t->set_var("img_block_tag", ""); # delete the image block $t->parse("swf_block_tag", "swf_block"); # fill in the swf block } else { $t->set_var("swf_block_tag", ""); # delete the swf block $t->parse("img_block_tag", "img_block"); # fill in the img block } # append this image tag to the IMG block $t->parse ("IMG", "img_tags", true); } $t->parse("output", "page"); $t->p("output"); ?> :::::::::::::: output :::::::::::::: <html> <body> img src="images/image1.gif" size<br> swf src="images/movie2.swf" size<br> swf src="images/movie3.swf" size<br> img src="images/image4.jpg" size<br> </body> </html> |
From: Abu H. <ab...@tr...> - 2001-08-16 04:52:58
|
I saw there is no special variabel to select value, using template (IF), example: {TMPL_IF VAR=1} do 1 {TMPL_ELSE} do 2 {/TMPL_IF} how to do it on template class? ~abu~ |
From: Richard A. <rh...@ju...> - 2001-08-15 21:31:11
|
At 12:21 PM -0400 15/8/01, Jesse Swensen wrote: >Just re-declare them. Something like... Or set them at run-time. class MyClass { var $var1 = 1; var $var2 = 2; someFunction() { } } class MySubClass extends MyClass { someFunction() { } } $m = new MySubClass(); $m->var1 = 3; $m->var2 = 4; ...R. |
From: Richard A. <rh...@ju...> - 2001-08-15 21:18:19
|
At 9:05 AM +0100 15/8/01, Peter Bowyer wrote: >Hi list, > >I need to test whether a table exists in the database, showing data from it >if it does, and showing a button telling the user to "Create the table" if >it doesn't. However, all SQL I've tried throws up the following error: Open a connection to the database server, select the database and run the query "show tables". You'll get back a result set like: mysql> show tables; +-----------------------+ | Tables_in_j0_phplib | +-----------------------+ | active_sessions | | active_sessions_split | | auth_user | | auth_user_md5 | | db_sequence | +-----------------------+ 5 rows in set (0.00 sec) Just loop through the results looking for your table. ...R. |
From: Jesse S. <ph...@sw...> - 2001-08-15 16:21:26
|
Just re-declare them. Something like... class MyClass { var $var1 = 1; var $var2 = 2; someFunction() { } } class MySubClass extends MyClass { var $var1 = 3; var $var2 = 4; someFunction() { } } > From: Peter Bowyer <re...@f2...> > Date: Wed, 15 Aug 2001 13:25:03 +0100 > To: phplib List <php...@li...> > Subject: [Phplib-users] Question on subclassing > > Hi, > > I understand how to subclass the functions in a class, or add new > functions. My question is how do I subclass the var $varname ones? I want > to subclass the following: > > /* public: configuration parameters */ > var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() > var $Debug = 0; ## Set to 1 for debugging messages. > var $Halt_On_Error = "no"; ## "yes" (halt with message), "no" (ignore > errors quietly), "report" (ignore errror, but spit a warning) > > to allow me to specify debug and Halt_On_Error without editing the real > classes, which makes it much easier to upgrade PHPLib. > > Thanks, > Peter. > > --oOo-- > Narrow Gauge on the web - photos, directory and forums! > http://www.narrow-gauge.co.uk > --oOo-- > Peter's web page - Scottish narrow gauge in 009 > http://members.aol.com/reywob/ > --oOo-- > > > _______________________________________________ > Phplib-users mailing list > Php...@li... > http://lists.sourceforge.net/lists/listinfo/phplib-users |
From: Peter B. <re...@f2...> - 2001-08-15 12:26:16
|
Hi, I understand how to subclass the functions in a class, or add new functions. My question is how do I subclass the var $varname ones? I want to subclass the following: /* public: configuration parameters */ var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() var $Debug = 0; ## Set to 1 for debugging messages. var $Halt_On_Error = "no"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) to allow me to specify debug and Halt_On_Error without editing the real classes, which makes it much easier to upgrade PHPLib. Thanks, Peter. --oOo-- Narrow Gauge on the web - photos, directory and forums! http://www.narrow-gauge.co.uk --oOo-- Peter's web page - Scottish narrow gauge in 009 http://members.aol.com/reywob/ --oOo-- |
From: Peter B. <re...@f2...> - 2001-08-15 08:06:01
|
Hi list, I need to test whether a table exists in the database, showing data from it if it does, and showing a button telling the user to "Create the table" if it doesn't. However, all SQL I've tried throws up the following error: Database error: Invalid SQL: select count(*) as count from sendcard_stats MySQL Error: 1146 (Table 'sendcarddb.sendcard_stats' doesn't exist) Session halted. There must be some way to do this... oh and did I say, it has to be cross-db compatible (work on as many of the db_xxx.inc drivers as possible) Please can someone tell me how to do this? Thanks, Peter. --oOo-- Narrow Gauge on the web - photos, directory and forums! http://www.narrow-gauge.co.uk --oOo-- Peter's web page - Scottish narrow gauge in 009 http://members.aol.com/reywob/ --oOo-- |
From: Guenther T. <th...@eq...> - 2001-08-15 07:53:24
|
Hi Jesse, you wrote: > You may want to look at the table class. You pass it a SQL statement > already ran through the $db->query() command and it builds the table for you > from the data selected. You can even tell it you want to have column > headers and it will pull them out of the select. Thanks for the tip, but now I've got problems to get the table-class to work together with the templates. Let's say I've got $foo which is sent to the template to replace {bar}. How do I get the results e.g. of show_result() into $foo? I tried $foo.=$table->show_result($db,$class=""); but this just prints out the results and doesn't put them into $foo. Where is my mistake? tia. Guenther |
From: Layne W. <la...@if...> - 2001-08-14 17:42:36
|
> anyway to change this so its more like > $tpl->clear_var("some_block");=20 > and have it clear all the vars that have been set in some_block? You could do that if you wanted to regex all of the vars in the block. = My goal was to gratify my laziness with minimal overhead. I was tired of = doing: $tpl->set_var(array("a_var" =3D> "", "another_var" =3D> "", "yet_again" =3D> "", "ad_nauseum" =3D> "")); > if there are 20 optional vars, then I would have to call this function = 20 times. > I'd rather clear them all, and reassign the ones I need to - which = need to be reassigned anyway Look at the function again - that's why it takes a string _or an array_. $tpl->clear_var(array("a_var", "another_var", "yet_again", "ad_nauseum")); Don't worry, I'm not proposing this as the next best improvement for template.inc; I simply wanted to show that even though this isn't Perl, still there _is_ more than one way to do it. Layne Weathers Ifworld Inc |
From: Daniel B. <bo...@io...> - 2001-08-14 17:05:57
|
YW55d2F5IHRvIGNoYW5nZSB0aGlzIHNvIGl0cyBtb3JlIGxpa2UNCiR0cGwtPmNsZWFyX3Zhcigi c29tZV9ibG9jayIpOyANCmFuZCBoYXZlIGl0IGNsZWFyIGFsbCB0aGUgdmFycyB0aGF0IGhhdmUg YmVlbiBzZXQgaW4gc29tZV9ibG9jaz8N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Gxpc3QoLCR2YWx1 ZSkgPSBlYWNoKCR2YXJuYW1lKSkgeyANCgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICR0aGlzLT5zZXRfdmFyKCR2YWx1ZSwgIiIpOyANCgkgICAgICAgICAgICAgICAgICAgICAgICB9 IA0KCSAgICAgICAgICAgICAgICB9IGVsc2UgeyANCgkgICAgICAgICAgICAgICAgICAgICAgICAk dGhpcy0+c2V0X3ZhcigkdmFybmFtZSwgIiIpOyANCgkgICAgICAgICAgICAgICAgfSANCgkgICAg ICAgIH0gDQoJICANCg0KCUxheW5lIFdlYXRoZXJzIA0KCUlmd29ybGQgSW5jIA0KDQo= |
From: Arno A. K. <ka...@tn...> - 2001-08-14 15:23:38
|
well i've just about got PHPAPP stripped down to my first public release version. and want to find out more about licensing, copyrights. would like to do some thing like postgresql where mine is mine, mine+clients ismine+clients, and some form of lgpl, gpl is public any urls would be apreciated. Features support multiple applications support 3 levels of defaults, per database, per application, per user common admin functions for users, printers, applications, permissions, defaults report engine that supports pcl (printer control lang), html, text gives frame work to structure spagetti state machines into procedures of state machines premissions are on common, and per application level data replication (mine + client only) easy to addon common features, and common admin functions online editable reports, help files for developers integrated bug reporting so clients can send in bug reports as they find them, with useful data, comments, etc.. no classes ever become persitant instead, assocate array is used to init classes for reuse. which means you don't have to drag evry class with you to display simple page to ask the user do you realy wish to delete the record. (was very anoying with some php classes) fits on top of my slightly hack phplib, am looking forward to make it work on the next stable release of phplib. lots of security checks and enhancments Applications (don't have a public one yet) was thinking mp3 juke box. Accounting, Time tracking, Project Management, Bug Processing/Tracking Email reader, News Reader, Various admin monitoring programs feeding my status page. -- My opinions are my own and not that of my employer even if I am self employed |
From: Tarique S. <ta...@sa...> - 2001-08-14 15:21:41
|
On 14 Aug 2001, Kristian Koehntopp wrote: > >possible. However... there are occasions when you have to have PHP in the > >templates, > > No there aren't. There are cases where templates are not useful, though. Very precisely stated - In fact, I am vehemently against all attempts to make templates intelligent (as some people would put it) PHP itself is intelligent enough :-) Tarique -- ========================================= B2B Application Providers http://www.sanisoft.com Vortal for Nagpur http://nagpurcity.net ========================================= |
From: Jesse S. <ph...@sw...> - 2001-08-14 14:20:29
|
You may want to look at the table class. You pass it a SQL statement already ran through the $db->query() command and it builds the table for you from the data selected. You can even tell it you want to have column headers and it will pull them out of the select. > From: Guenther Theilen <th...@eq...> > Reply-To: Guenther Theilen <th...@eq...> > Date: Tue, 14 Aug 2001 15:44:30 +0200 > To: php...@li... > Subject: [Phplib-users] templates and tables > > Hi, > > as promised here is another newbie question... ;-) > I hope my English is good enough to explain the problem. > I'm looking for an elegant way to get data from a database into a > table. > In this special case, I've got a lot of links which are ordered by a > certain subject. Now I want this links to be put in a table with three > coloumns which is defined as a template. > The template looks something like this: > <table> > {linktype1} > </table> > <table> > {linktype2} > </table> > > It's no problem to replace {linktype1} by a couple of tablerows > existing of three coloums whith the links in it, although this doesn't > seem very elegant to me, especially if I (better: the designer) wants a > dot (gif-file) in front of every link. This dot is changing with the > template. > > Anybody any hints? > > Thanks for your patience. > > Guenther > > > _______________________________________________ > Phplib-users mailing list > Php...@li... > http://lists.sourceforge.net/lists/listinfo/phplib-users |
From: Layne W. <la...@if...> - 2001-08-14 14:11:16
|
> forgot to say, that I only wanna set address2 if it exists > > if ($q->f("address1")) { > $tpl->set_var("address2",$q->f("address1")."<br>"; > } eles { > $tpl->set_var("address1",""); > } For what it is worth, I have extended my template class with a clear_var() function (below). After parsing each loop, I call clear_var() with the varname(s) that may be blank. For instance: while($db->next_record()) { $tpl->set_var("some_var", $db->f("some_var")); if($db->f("optional_var")) $tpl->set_var("optional_var", $db->f("optional_var")); $tpl->parse("some_block", "some_loop", true); $tpl->clear_var("optional_var"); } I really appreciate it on large blocks with several optional variables. Here's my function: /* public: clear_var(array $varnames) * varnames: array of variable names to be cleared * * public: clear_var(string $varname) * varname: name of a variable that is to be cleared */ function clear_var($varname) { if(is_array($varname)) { while(list(,$value) = each($varname)) { $this->set_var($value, ""); } } else { $this->set_var($varname, ""); } } Layne Weathers Ifworld Inc |
From: Guenther T. <th...@eq...> - 2001-08-14 13:51:34
|
Hi Richard, you wrote: > The concept of templates is to separate the HTML from the logic. > If you start putting logic in the template (whether that's embedded > PHP code or some sort of IF tag) you're creating something *very* > complicated. OK, I see the point. Thank you all for the answers. But there is yet another newbie question... ;-) (See other mail) Guenther |
From: Guenther T. <th...@eq...> - 2001-08-14 13:44:49
|
Hi, as promised here is another newbie question... ;-) I hope my English is good enough to explain the problem. I'm looking for an elegant way to get data from a database into a table. In this special case, I've got a lot of links which are ordered by a certain subject. Now I want this links to be put in a table with three coloumns which is defined as a template. The template looks something like this: <table> {linktype1} </table> <table> {linktype2} </table> It's no problem to replace {linktype1} by a couple of tablerows existing of three coloums whith the links in it, although this doesn't seem very elegant to me, especially if I (better: the designer) wants a dot (gif-file) in front of every link. This dot is changing with the template. Anybody any hints? Thanks for your patience. Guenther |
From: Peter B. <re...@f2...> - 2001-08-14 12:54:43
|
Kristian wrote: >There is no problem. Just release your changes to phplib as >LGPL, as the license requires you to do this. Your own >application is unaffected. OK, well here goes :-) I have developed a way of using PHP in the template files. Yes I know, the whole point of templates is to separate HTML and PHP. However, in my case I had developed a postcard application (sendcard - http://www.sendcard.f2s.com/ ) which people were using in existing sites. These sites were using included files for the design, and the people didn't want to keep a template with the design in as well, or rebuild the site using templates. So don't flame please, I coded to suit my users' needs, which at the end of the day is what it is all about. Credit for the code goes to Robin Vickery, who very kindly wrote the regular expression and function for me (I'm not that good with PCRE). I'm sure my code could be made neater by putting the functions into the class as well, but I'm not experienced enough with classes to do so. Just two notes before the code: 1. It will only work with PHP 4.0.5 or greater. 2. I subclassed template.inc and copied the whole function loadfile() and modified it. I then stuck the external functions below in the file. To add the code: At the bottom of function loadfile(), just before $this->set_var($varname, $str); add the following line: $str = preg_replace_callback('#<\?php(.+?)\?>#', 'evalTag', $str); And the external function: /* * This function replaces the PHP in the templates with the eval'd equivilent. * * @author Robin Vickery <ro...@ec...> * @param $match, the array of items matched using preg_replace_callback. * @return The eval()'d version of $match. */ function evalTag( $match ) { ob_start(); eval( $match[1] ); $replacement = ob_get_contents(); ob_end_clean(); return $replacement; } One other extension I have found useful for template.inc, which I hope will be included in a future version, was written by R.B. Scholtus <reg...@dd...> and is very useful for deleting a block from a template. function del_block($container, $handle) { $this->set_block($container, $handle); $this->set_var($handle, ""); } I hope these are useful to some people. The code is being used in sendcard 3, which will be released in less than a week, so download it if you are interested and try it out! Regards, Peter. ---oOo--- Do you sendcard? http://www.sendcard.f2s.com/ PHP postcard script supporting 9 databases! ---oOo--- Keywords for marc searchengine: PHP in template, delete block, execute template. |
From: Peter B. <re...@f2...> - 2001-08-14 12:41:06
|
At 12:40 PM 8/14/01 +0200, you wrote: > > You don't want to be executing your templates!! >Why don't I? (Sorry, I just start working with the PHPLIB.) Well, it's best to separate PHP and HTML completely if possible. However... there are occasions when you have to have PHP in the templates, and I wrote some code which allows you to do so, providing you are using PHP 4.0.5 or greater. Code will follow later... Cheers, Peter. ---oOo--- Do you sendcard? http://www.sendcard.f2s.com/ PHP postcard script supporting 9 databases! ---oOo--- |
From: Tarique S. <ta...@sa...> - 2001-08-14 11:32:51
|
On Tue, 14 Aug 2001, Guenther Theilen wrote: > > You don't want to be executing your templates!! > > Why don't I? (Sorry, I just start working with the PHPLIB.) Because templates are meant to separate your code from design. There are some templates available which allow some sort of meta language in them but that defeats the purpose of templates. Templates are typically used for large projects where the designers are a separate groups and most often at loggerheads with the programmers. So in a ideal world if you separate design from code then the work becomes easier and things like changing the looks of the site can be done by the designers alone. HTH Tarique -- ========================================= B2B Application Providers http://www.sanisoft.com Vortal for Nagpur http://nagpurcity.net ========================================= |
From: Richard A. <rh...@ju...> - 2001-08-14 11:32:43
|
At 12:40 PM +0200 14/8/01, Guenther Theilen wrote: >> You don't want to be executing your templates!! > >Why don't I? (Sorry, I just start working with the PHPLIB.) The concept of templates is to separate the HTML from the logic. If you start putting logic in the template (whether that's embedded PHP code or some sort of IF tag) you're creating something *very* complicated. Much better (IMHO) to program the logic into the PHP script and use the template to control the layout of the page. I have seen one or two cases where if clauses and loops appeared to be suitable in a template, but in each case I thought the overall result was more complicated to maintain and configure than it would have been with the logic all in the PHP application. My rant isn't particularly relevant in your situation, as the job you want done is perfectly suited to the existing template.inc :) ...R. |