This topic is locked

Events?

1/13/2007 3:16:47 PM
PHPRunner General questions
E
ERuiz author

How do events work? Can I do some formatting on certain field values BEFORE they are displayed on the List page? For instance, I have a field named "OriginAirport" and the value would be something like "KJFK - Kennedy Intl".
Before List Page displays this value, I need the script to do an explode() command on the value so that only "KJFK" is displayed instead of "KJFK - Kennedy Intl".
The actual explode routine would be this:

$query = "SELECT * FROM pirep ORDER BY CreatedON DESC";

$result = mysql_query($query) or die("SQL query failed.");

$row = mysql_fetch_object($result)
$exorigapt = explode(" ",$row->OriginAirport);

$origapt = $exorigapt[0];


Can this actual code be used as an event or do I just need to do something simpler? Maybe the field OriginAirport is already being passed as a variable and all I need to do is something like this:

$exorigapt = explode(" ", $OriginAirport);

$OriginAirport = $exorigapt[0];


Is this correct? Am I on the right track? Did I completely lose it? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4375&image=1&table=forumtopics' class='bbc_emoticon' alt=':lol:' />

J
Jane 1/15/2007

Hi,
you can do it using Custom format on the "View as" settings dialog on the Visual Editor tab.

Here is the sample code:

$exorigapt = explode(" ", $value);

$value = $exorigapt[0];