phplib-users Mailing List for PHPLIB (Page 94)
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: Tarique S. <ta...@sa...> - 2001-08-14 11:28:40
|
On Tue, 14 Aug 2001, Richard Archer wrote: > At 11:38 AM +0200 14/8/01, Guenther Theilen wrote: > You don't want to be executing your templates!! Yep! this is exactly what templates are not supposed to do - execute code. > There are two choices here. The way I'd normally do it is to set up my > template like: > <a href="test.php{sess_url_suffix}">foo</a> IMHO a cleaner way would be have in template <a href="{test_url}">foo</a> Then in your code $test_url = $sess->url(test.php).$sess->padd_query(array("again"=>"yes")) set_var("test_url", $test_url); Need not worry about grabbing things after '?' etc etc. Also it would be cool if we can have some predefined template variables like {sessID}, {selfURL} which will do - well the obvious Not too much of a problem to implement either ... .... Just my 2p Cheers Tarique -- ========================================= B2B Application Providers http://www.sanisoft.com Vortal for Nagpur http://nagpurcity.net ========================================= |
From: Guenther T. <th...@eq...> - 2001-08-14 10:40:50
|
Hi Richard, you wrote: > You don't want to be executing your templates!! Why don't I? (Sorry, I just start working with the PHPLIB.) > There are two choices here. The way I'd normally do it is to set up my > template like: > <a href="test.php{sess_url_suffix}">foo</a> Yes, I thought about something like that, but then I thought there might be a better way to handle it. ;-) > The nicer way was posted by Lukasz Kowalczyk to the old phplib mailing > list back in May 2000 and involves a patch to template.inc so that it > knows about session URLs. Thanks, I'll take a look at that. Guenther |
From: Richard A. <rh...@ju...> - 2001-08-14 10:09:03
|
At 11:38 AM +0200 14/8/01, Guenther Theilen wrote: >I'm working with templates and session. Now I want to replace the >regular links (e.g. <a href="test.php">foo</a>) in my >index.tpl.html-teplate file by something like this: ><a href=" $sess->url('test.php') ">foo</a> >But I'm not able to figure out how to get php to parse the php-part in >the file. Renaming the index.tpl.html to index.tpl.php had no effect. >Anybody any hints? Hi Guenther, You don't want to be executing your templates!! There are two choices here. The way I'd normally do it is to set up my template like: <a href="test.php{sess_url_suffix}">foo</a> Then generate a sess_url, grab the bit from the '?' to the end into $sess_url_suffix and do: set_var("sess_url_suffix", $sess_url_suffix) Obviously a pretty nasty hack to work around a missing template.inc feature. The nicer way was posted by Lukasz Kowalczyk to the old phplib mailing list back in May 2000 and involves a patch to template.inc so that it knows about session URLs. Note that I've never tried this patch, and it should be implemented by subclassing Template and overriding the existing finish function. A snippet of the patch is below. Please excuse the long lines. ...Richard. * str: string to finish. */ function finish($str) { global $sess; /* First substitute all URLs which contain question marks (in this case session id * is appended after an ampersand (&). With the next pass substitute URLs not containing * question marks - this time use `?' as a separator. */ if (isset($sess) && $sess->mode == "get") { $str = preg_replace('/<[aA]([^>]+)[hH][rR][eE][fF]="(([^"?]+)\?([^"?]*))"/', '<a\1href="\2&'.$sess->cookiename.'='.$sess->id.'"', $str); $str = preg_replace('/<[aA]([^>]+)[hH][rR][eE][fF]="([^"?]+)"/', '<a\1href="\2?'.$sess->cookiename.'='.$sess->id.'"', $str); $str = preg_replace('/(<[fF][oO][rR][mM][^>]*>)/', '\1<input type="hidden" name="'.$sess->cookiename.'" value="'.$sess->id.'">', $str); } switch ($this->unknowns) { case "keep": break; |
From: Guenther T. <th...@eq...> - 2001-08-14 09:39:01
|
Hi, yet another newbie question. ;-) I'm working with templates and session. Now I want to replace the regular links (e.g. <a href="test.php">foo</a>) in my index.tpl.html-teplate file by something like this: <a href=" $sess->url('test.php') ">foo</a> But I'm not able to figure out how to get php to parse the php-part in the file. Renaming the index.tpl.html to index.tpl.php had no effect. Anybody any hints? tia. Guenther |
From: Richard A. <rh...@ju...> - 2001-08-14 07:54:46
|
At 12:26 AM -0700 14/8/01, Philip Strnad wrote: >the whole template processing would be negligible. So how do you do it? Are >your templates parsed dynamically? Yes, they're read in and have the content substituted on the fly. >Btw, maybe one way to speed things up would be to read the templates into >memory at server startup, but I'm not sure if this is possible in PHP? Never heard of it. Note that if you've got a busy server (and if your server isn't busy, why worry about performance ;) and the server has enough RAM, the template files will all be in cache anyway. In any event, the cost of reading in the template file is way lower than the cost of generating the dynamic content and performing the substitution. If you're using templates and databases to generate pages that are not unique *every* time (like, say a news releases page that pulls articles out of a database and is updated only every hour or so) then you can cache the built pages on disk and not even bother regenerating the dynamic content each time. You'd still need to pull a timestamp of the last inserted record out of the database but if there's no change, you can just blat out the last version of the page from cache. There was a patches that did something like this with template.inc posted by Tom Anderson to the NetUSE mailing list a long time ago. Sort of a roll-your-own Zend cache :) ...R. |
From: Philip S. <ph...@st...> - 2001-08-14 07:26:32
|
> I think you'll find the overhead from templates is a lot lower than the > overhead from other aspects of your dynamic pages. For example, a call > to preg_replace is much cheaper than the cost of bringing up a database > connection. True. In my situation the db connection would already be there, so I guess the whole template processing would be negligible. So how do you do it? Are your templates parsed dynamically? > If you do run some performance figures, be sure to post them back to > the list... that always generates a lot of interest. I will see what I can come up with. I doubt I'll be getting to this anytime soon, but you never know what's going to happen since requirements change. Btw, maybe one way to speed things up would be to read the templates into memory at server startup, but I'm not sure if this is possible in PHP? I know it can be done with mod_perl, but that's totally different. Philip |
From: Richard A. <rh...@ju...> - 2001-08-14 07:15:51
|
At 11:52 PM -0700 13/8/01, Philip Strnad wrote: >> supposed to be, but I have one question: does anyone use Template for >> dynamic pages or do most of you use it to "write" HTML files that are >> then served statically? Template's real strength is in simplifying the handling of dynamic pages. it allows you to write PHP code that contains no HTML -- it's all in the template files. Of course with *really* complex pages it can be a lot of work to get *all* HTML out of the code, and you'll have to decide when to stop based on a cost/benefit analysis. The best thing though is that when the boss decides to redesign the site all you have to do is re-jig your template files. In theory! >> Is there a performance impact in opening a >> template file everytime a page that uses the Template class is >> requested? I think you'll find the overhead from templates is a lot lower than the overhead from other aspects of your dynamic pages. For example, a call to preg_replace is much cheaper than the cost of bringing up a database connection. Only way to tell for sure is to try it and see :) If you do run some performance figures, be sure to post them back to the list... that always generates a lot of interest. ...R. |
From: Philip S. <ph...@st...> - 2001-08-14 06:53:10
|
Sending this to the new list. Philip Strnad wrote: > All, > > I've been using PHPLIB since the 6.x days and have never used the > Template class (please don't flame me!). I always had too many other > things going on to take a look at it. I know how great this class is > supposed to be, but I have one question: does anyone use Template for > dynamic pages or do most of you use it to "write" HTML files that are > then served statically? Is there a performance impact in opening a > template file everytime a page that uses the Template class is > requested? My whole site could work really well with templates. > Unfortunately most of the pages are dynamic so I'm not sure if templates > are the right way to go. > > Thanks, > Philip > > -- > Abbestellen mit Mail an: php...@li... > Kommandoliste mit Mail an: php...@li... |
From: Richard A. <rh...@ju...> - 2001-08-14 01:12:36
|
At 5:14 PM -0700 13/8/01, Daniel Bondurant wrote: >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",""); >} Yup, that's how I'd do it (typos excluded :). Is that not what you are looking for? Oh, and I think you're missing a "true" to your parse call... you probably want to append these records. ...R. |
From: Daniel B. <bo...@io...> - 2001-08-14 00:14:53
|
sorry, may bad 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",""); } if ($q->f("address2")) { $tpl->set_var("address2",$q->f("address2")."<br>"; } eles { $tpl->set_var("address2",""); } if ($q->f("address2")) { $tpl->set_var("city",$q->f("city")."<br>"; } eles { $tpl->set_var("city",""); } then in the html I have=20 {address1}{address2}{city}{state}{zip} so I don't get a blank line if address2 does not exist. -----Original Message----- From: Richard Archer [mailto:rh...@ju...] Sent: Monday, August 13, 2001 5:08 PM To: php...@li... Subject: Re: [Phplib-users] dumping vars in a block At 4:41 PM -0700 13/8/01, Daniel Bondurant wrote: >I am using the template class. >I have a repeating block in a while loop with about 25 vars in it. >... >not every record is going to have address2 >how do I clear out all the vars in this block before setting them all >for the current record and parsing again. Won't the line: $tpl->set_var("address2",$q->f("address2"); clear the var if there's no value? ...Richard. _______________________________________________ Phplib-users mailing list Php...@li... http://lists.sourceforge.net/lists/listinfo/phplib-users |
From: Richard A. <rh...@ju...> - 2001-08-14 00:08:38
|
At 4:41 PM -0700 13/8/01, Daniel Bondurant wrote: >I am using the template class. >I have a repeating block in a while loop with about 25 vars in it. >... >not every record is going to have address2 >how do I clear out all the vars in this block before setting them all >for the current record and parsing again. Won't the line: $tpl->set_var("address2",$q->f("address2"); clear the var if there's no value? ...Richard. |
From: Daniel B. <bo...@io...> - 2001-08-13 23:41:13
|
I am using the template class. I have a repeating block in a while loop with about 25 vars in it. something like this while($q->next_record()) { $tpl->set_var("firstname",$q->f("firstname"); ... $tpl->set_var("address2",$q->f("address2"); ... $tpl->parse("addresses",'addressblock") } not every record is going to have address2 how do I clear out all the vars in this block before setting them all for the current record and parsing again. thanks |
From: Dima N. <Dim...@lu...> - 2001-08-13 23:25:28
|
> Date: Sun, 12 Aug 2001 18:30:26 -0400 (EDT) > From: "nathan r. hruby" <na...@ds...> > To: <php...@li...> > Subject: [Phplib-users] Test > > <tap><tap><tap><tap><screeeech> > Is this thing on? > > -n > -- > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > nathan hruby / digital statement > na...@ds... > http://www.dstatement.com/ > > Public GPG key can be found at: > http://www.dstatement.com/nathan-gpg-key.txt > ED54 9A5E 132D BD01 9103 EEF3 E1B9 4738 EC90 801B > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- I hear ya. -- :D_ima Dima Nemchenko <Dim...@lu...> "Open source code is like lobster--most people who haven't tried it don't like the way it looks. But those who try it, love it." |
From: Martin L. <mar...@ma...> - 2001-08-13 05:20:51
|
Hi Nathan. > <tap><tap><tap><tap><screeeech> > Is this thing on? Sure seems like it. Regards, Martin |
From: nathan r. h. <na...@ds...> - 2001-08-12 22:24:01
|
<tap><tap><tap><tap><screeeech> Is this thing on? -n -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- nathan hruby / digital statement na...@ds... http://www.dstatement.com/ Public GPG key can be found at: http://www.dstatement.com/nathan-gpg-key.txt ED54 9A5E 132D BD01 9103 EEF3 E1B9 4738 EC90 801B -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |