#native_company# #native_desc#
#native_cta#

PHP Templates: Revisited Page 5

By Polerio Babao
on 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.

<?php

function EmptySpace($Prefix=""$LoadTemplate="")

{

    
$tcontent $LoadTemplate;

    
$startnolist strpos($tcontent,"<!--%".$Prefix."_BEGIN_NO_MESSAGES%-->");

    
$endnolist strpos($tcontent,"<!--%".$Prefix."_END_NO_MESSAGES%-->")+27;

    $nomessagesline 

    
substr($tcontent,$startnolist+29,$endnolist-$startnolist-56);

    
$nomessageslinetoreplace 

    
substr($tcontent,$startnolist,$endnolist-$startnolist);

    $tcontent eregi_replace($nomessageslinetoreplace,"",$tcontent);

    return 
$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 phpmylibrary.sourceforge.net project.

1
|
2
|
3
|
4
|
5
|
6
|
7