Domain: thewebmasters.net
Stories and comments across the archive that link to thewebmasters.net.
Comments · 9
-
Went through this about a year ago.Browsers at work, browsers at home, booting different operating systems. Used to send myself email with links, still have a pile in the mail client that I've never visited again. Tried all sorts of bookmark merge programs, wasn't happy with some of those. Tried the Yahoo thing, was way past their limit of 1000 bookmarks. Tried the Blink thing and at least one other service that went out of business (deapleap I think), they were too slow even over my cable connection.
So I rolled my own, well actually I snagged the useful phpHoo, read the pages at webreference to lend myself a clue and put it up where I've got some cheap hosting. Now I just have to remember to use it instead of the browser bookmark functions. Advantages, well, its searchable, its available as long as my host is up, It lets you create tree like organization kind of like Yahoo, and some other stuff I can't think of now. It doesn't import other bookmarks, but I think that would be a good challenge for my limited skills. I also think some buttons tied to 'scriptlets' for the most popular browsers would be a great useability addition, that way you could make the system nearly as painless as a bookmark file.
Looks like some more stuff has come out since I did this, I might take another look at the alternatives. But take a look at phpHoo and its relatives, they just might work like you want them to.
-
Re:Why embed scripts in HTML anyway?
Try FastTemplate.
or Smarty which also processes the templates into ordinary php files on the first run (to reduce overhead).
Also PHPLIB which has many other uses including session an database management.
DILBERT: But what about my poem? -
PHP's got templating, as I say above
class.FastTemplate.php3, a port of a perl module (I believe it's CGI::FastTemplate, but go to the page and see) allows you to separate logic from HTML.
-
In defense of PHP
PHP suffers from many of the same problems as CGI (logic and HTML combined in the same place, etc)
This is true in one sense, false in another. The CGI::FastTemplate module for Perl, which allows you to separate your logic from your HTML, has been ported (quite successfully, I might add) to PHP. Granted, in neither case is templating a builtin feature of the language, but it's easily available to those who want it.
That said, some other criticisms you level (such as that PHP is not as integratable with the webserver as Perl is with Apache and mod_perl) are valid; but don't forget, you can always compile mod_perl into your PHP-enabled Apache server =)
-
PHP and Fast Templates
If you're already using Apache, then it's worth taking a look at PHP (www.php.net). PHP is an open source project that has done an incredible job of competing with ColdFusion, Active Server Pages, and the like. To go along with your question, PHP offers a class called FastTemplates that does exactly what you want. The newer version even uses a caching algorithm that makes it even faster. You can read about it here: www.phpbuilder.com/columns/sa scha19990316.php3 and you can download it here: www.thewebmasters.net/php/
-
Re:I use perl but...You should be using FastTemplates. It's a nice way to do this with Perl. But then, why haven't you switched to PHP anyway? It's so much less painful than web programming in Perl.
For templates for PHP, see my other reply "Your Answer - TEMPLATES", posted in reply to the original slashdot question. dave.
-
Your Answer - TEMPLATESBasically what you're asking for is templates. PHP is designed to be an HTML-embedded language, but for people who want to separate the PHP from the HTML and text, you can use templates. Once you're using templates, it's easy to create scripts that choose a template for whichever language is currently selected.
There are two routes you can go for using templates with PHP, FastTemplates and the PHP Base Library's ("PHPLIB") Template.
So how are they different? FastTemplates was originally a Perl library that was ported to PHP. FastTemplates works well for Perl programs, but it's not ideal for PHP. Kristian Koehntopp wrote PHPLIB Template from the ground up as a pure PHP library to better take advantage of the capabilities of PHP. One advantage to Kristian's design is that it parses templates with preg_replace(), which is said to be faster than FastTemplate's reliance on ereg_replace(). Another advantage of PHPLIB Template is it allows dynamic blocks to be nested, unlike FastTemplates.
For those reasons I prefer to use PHPLIB Template, but you do have a choice of the two libraries.
It may be worth also mentioning the XML approach. XLT is an XML based format for templates, so you might want to look into that. PHP4 can parse XML, but there isn't code to specifically parse XLT as far as I know. XML or XLT are options if you need them, but they're probably more involved then you would need for most PHP projects that really just need templates.
And for a nice tutorial on PHPLIB Template, look for my article on phpbuilder.net sometime soon (assuming the editor over there decides he wants to publish it). But even if my article doesn't get put online there, it is a very nice site for PHP info.
-
FastTemplate
-
Re:PHP seems broken by design.Perl, when used incorrectly, suffers from the same problem. The solution for complex scripts is to put the html code in templates just as you would in Perl. (See here for a fast templating package for Php.
Keep in mind that this is a design decision: allowing you to put code in your html makes sense when all you want is one or two lines of script.