Re: mixing HTML and PHP code

From: Date: Sat, 13 Jan 2001 06:05:07 +0000
Subject: Re: mixing HTML and PHP code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34346@lists.php.net to get a copy of this message
thanks I haven't thought about sharing the code, but it would be easy because our code is as abstract as possible. In fact there a few files which contain most of the "HTML replacements" that can be used on basically any site without modification. I'm too busy at the moment, I think I'll package my implementation for anyone who is interested. BTW in general I always name functions in this sort of style: category_specific_morespecific() meaning that ideally all my HTML replacement functions would be named something like html_tr() and html_head(). The reason I didn't do that was to make these functions we use all the time shorter to type and the code easier to read. Also a lot of my functions are flexible such as blockquote( $text = '' ) where if you specify some text it is enclosed in blockquote tags or if you don't it just opens the tag. ex, the following are the same: blockquote('print this text'); blockquote(); echo 'print this text'; x('blockquote'); Let me show you an example from our site, go to http://bandwidthplace.com/speedtest.html and run a test so you get to the results screen. (this example will only work for a few more days because we are debuting an all new speed test, I'm really excited about it) Anyway look at the explanations below the results box, those are printed by: $content = (function that grabs the text from our database); while(list($title, $text) = each($content)) { main_title1($title, BLUE2); blockquote($text); } that's it. ............. Jade Ohlhauser [website architect]........... http://bandwidthplace.com ----- Original Message ----- From: "Kulkarni, Vikram" <Vikram.Kulkarni@lewcosec.com> To: "'Jade Ohlhauser'" <jade@bandwidthplace.com> Sent: Friday, January 12, 2001 2:52 PM Subject: RE: [PHP] mixing HTML and PHP code > Hello Jade: > > I like your idea of using functions instead of HTML. It must simplify the > work tremendously. Is there any place you have published these functions? > I would love to take a look at them. I am a newbie PHP programmer and am > trying to learn from masters :-) > > Thanks, > > Vikram Kulkarni > > -----Original Message----- > From: Jade Ohlhauser [mailto:jade@bandwidthplace.com] > Sent: Thursday, January 11, 2001 9:41 PM > To: PHP List > Subject: Re: [PHP] mixing HTML and PHP code > > > ****** Please Note: This message came from the INTERNET. ****** > > > You _actually_ print() or echo() everything you want to send to the > > browser? > > Absolutely. We've replaced every HTML tag we use often with PHP functions. > We separate content, style, layout, and logic so using 100% PHP is the best > for us. > > > if you have ever worked in a fast paced production environment, where html > > is changed sometimes 5 times a day, digging through hundreds of lines of: > > > > echo "<input type=\"text\" name=\"hello\" > > size=\"20\" value=\"$value\">" > > > > starts to make you insane. > > > > speaking as an html author, and a lover of php, _please_: > > > > <input type="text" name="hello" size="20" > > value="<?=$value?>"> > > > > it makes the code useable. > > IMHO even better is: > input_text('hello', 20, $value); > > that's how that would appear on our site. We order the parameters logically > and include a catch all final parameter that will add text to the HTML tag. > > > echo "<html>"; > > echo "<head>"; > > echo "<title>$title</title>"; > > echo "<link rel='stylesheet' type='text/css' > > href='resources/css/$css.css'>"; > > echo "<script src='/resources/js/base_lib.js' > > language='javascript'></script>"; > > echo "</head>"; > > echo "<body bgcolor='#EEEEEE' text='#000000' > > link='#003366' > alink='#CCCCCC' > > vlink='#003366' topmargin='0' leftmargin='0' > > marginwidth='0' > > marginheight='0'>"; > > echo "<table border='0' cellpadding='0' > > cellspacing='0' width='100%' > > bgcolor="#000000">"; > > echo "<tr>"; > > echo "<td valign='top'><img > src='resources/images/binarycloud/tmpl/fire.jpg' > > alt='' width='466' height='161' > > border='0'></td>"; > > echo "</tr>"; > > echo "</table>"; > > > > it introduces a whole world of unnecessary complexity. > > > > to prove my point: > > > > get one of your friends that knows html but not PHP to look at the above, > > then this: > > > > <html> > > <head> > > <title><?=$title?></title> > > <link rel="stylesheet" type="text/css" href="resources/css/<?=$css?>.css"> > > <script src="/resources/js/base_lib.js" > > language="javascript"></script> > > </head> > > <body bgcolor="#EEEEEE" text="#000000" link="#003366" > > alink="#CCCCCC" > > vlink="#003366" topmargin="0" leftmargin="0" > > marginwidth="0" > > marginheight="0"> > > <table border="0" cellpadding="0" cellspacing="0" > > width="100%" > > bgcolor="#000000"> > > <tr> > > <td valign="top"><img > > src="resources/images/binarycloud/tmpl/fire.jpg" > > alt="" width="466" height="161" > > border="0"></td> > > </tr> > > </table> > > On our site that would more like: > > (comments) > > (include files) > > (page specific variables) > > html(); > > head($title); > head_css('stylesheet.css'); > head_script('script.js); > x('head'); > > body($style) > table(0, 0, 0, '100%', '', BLACK); > tr('top'); td(); image('fire.jpg'); x('td'); x('tr'); > x('table'); > > x('body'); > x('html'); > > Well it would be a bit different because we have other logic and comments > throughout, but you get the "jist" of it. > > BTW "image()" calls "img()" but adds the appropriate image directory to the > path. img() is a function that creates the img HTML tag along with > automatically finding out and adding the width and height parameters. I > can't imagine going back to manually editing those every time I change the > image dimensions. > > We have many people who contribute to this site. Some of them are content > editors with no technical expertise. Simply saying "saty away from code in > (these) tags" is not enough. 1.they don't have the HTML know how 2. I'm not > risking even that much access. They don't go anywhere near an editor or FT P > program, they do everything through interfaces we (the tech team) builds. > > ............. Jade Ohlhauser > [website architect]........... http://bandwidthplace.com > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > **************************************************************************** * > This message may contain privileged and confidential information. If you > think, for any reason, that this message may have been addressed to you in > error, you must not disseminate or copy this message, or use its content > as the basis for taking any action. Further, we would ask you to notify > us immediately by return e-mail, telephone or facsimile. > **************************************************************************** *

« previous php.general (#34346) next »