This topic is locked

Hide Empty Fields

1/25/2006 3:27:31 PM
PHPRunner General questions
T
Tommy B author

Is there a way to hide empty fields from showing up on the view page?
I've created a profile management system for our clients. Some clients may have 1 contact person others may have up to 6. Well, for the clients with 1, our employees have to scroll through all the empty fields for other contacts that don't exist. If there was a way to hide those empty fields it'd make the viewing aspect of the page much easier.

D
Dale 1/25/2006

Im fairly new to PHPRunner myself, but Im fairly confident that there is no

default switch to enable the visibility of the field if empty.
What I did for similiar wished for feature, to fill the broswer <td>[Data]</td>

with an &nbsp; to make tables more crossbrowser alike. Using a table with

borders ON and an empty cell in good old IE can make the table look badly.
Anyway what I might suggest is a script that will hide the element or in my

case to add "&nbsp;" before the </td> tag in my lists.
Create a template, and try it out.

I am not the most profecient with javascript so my effort worked on all fields BUT

the note field. Im sure if one was more understanding of javascript it would be hard

to get exactly what you are looking for.
I tried the below snippet to, as I said get more than half way there.

Im SURE this can be bettered.
in the LIST.PHP from your
find the section below

IEND## ##BEND##

/TEXTFIELD##



<!-- The ONE line below was added that fills the <td> with the space if there was data in the field.-->

<?php if ($data["##FIELD##"]=="") echo "&nbsp;"; ?>
</td>

/LISTFIELDS##

<?php $iNumberOfRows = $iNumberOfRows + 1; ?>
The point is, I am confident this can be done.

Im hoping someone can be more specific with a solution. Im sure it will help me out too.
Dale

admin 1/26/2006

Tommy,
you can create your custom template in PHPRunner 3.0 for hiding empty fields on View page.
Start Template Editor on Miscellaneous tab in PHPRunner, create a new template.

Open view.php file

Locate this snippet:

##VIEWFIELDS##

$i=array_search("##FIELD##",$fieldlist);

$value=$data["##FIELD##"];

echo "\r\n<tr><td class=shade>".Label("##FIELD##")." </td><td>";



and modify it this way:

##VIEWFIELDS##

$i=array_search("##FIELD##",$fieldlist);

$value=$data["##FIELD##"];

if($value)

{


echo "\r\n<tr><td class=shade>".Label("##FIELD##")." </td><td>";


Then find this fragment of code:

echo "</td></tr>";

/VIEWFIELDS



and replace it with:

echo "</td></tr>";

}

/VIEWFIELDS


Then close template editor and select your new template as the current on Miscellaneous tab in PHPRunner