PHPBuilder - PHP Templates: Revisited Page 5

RSS Twitter
Articles Html

PHP Templates: Revisited - Page 5

by: Polerio Babao
September 9, 2002

Erasing some of your HTML content

This kind of function will be needed because, sometimes you would like to hide the first result template. I made this script to limit my templates in displaying the full HTML. To have a clear grasp of what I am trying to imply read, this code line by line and you will see, it simply limits tables or sort of HTML tags so that it will not appear when not not needed.

function EmptySpace($Prefix=""$LoadTemplate="")
$tcontent $LoadTemplate;
$startnolist strpos($tcontent,"<!--%".$Prefix."_BEGIN_NO_MESSAGES%-->");
$endnolist strpos($tcontent,"<!--%".$Prefix."_END_NO_MESSAGES%-->")+27;


$tcontent eregi_replace($nomessageslinetoreplace,"",$tcontent);
I called it empty space for a purpose of creating space for HTML tags not yet needed. It has a $Prefix variable to determine which position to start replacing some content with a space. The $prefix + BEGIN_NO_MESSAGES probably gives us the idea where the parser will start replacing empty space.
I will provide an example of the script. Go through the script and run it on your localhost to see the purpose of the EmptySpace function. Briefly, this function only hides tables which have no values yet. You can use this if you want to stop tables you do not need from appearing. I made this because the loading of templates reads and parses the whole HTML file and, if you will not replace the table, you do not need a space -- you will end up into tables with no values or data in it. To benefit fully by this function, put this in a class and simply call it whenever you want. This function has been applied into my project.

« Previous Page
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Polerio Babao



(Maximum characters: 1200). You have characters left.