August 12, 200817 yr I'm having trouble using getFieldUnencoded in a recordlist.php page (it works fine in my browserecord.php page however). If if I have this in my recordlist.php page: <?php echo nl2br( $record->getFieldUnencoded('source_with_URL', 0))?> I get this error when trying to view the page: Fatal error: Call to undefined method RecordHighlighter::getFieldUnencoded() in C:Inetpubwwwrootsiteselected_records.php on line 115 If I change it to: <?php echo nl2br( $record->getField('source_with_URL', 0))?> I don't get the error but I don't see the field, which contains HTML. I suspect the problem related to this at the top of the table (I'm simply viewing the found recorcds from a search): <?php $recnum = 1; foreach ($records as $fmrecord) { $record = new RecordHighlighter($fmrecord, $cgi); $rowclass = ($recnum % 2 == 0) ? "table_row" : "alt_row"; $recid = $record->getRecordId(); $pos = strpos($recid, "RID_!"); if ($pos !== false) { $recid = substr($recid,0,5) . urlencode(substr($recid,strlen("RID_!"))); }?> I've been trying to change this for a few hours now and can't get past this error - can anyone point me in the right direction? Many thanks, Steve
August 13, 200817 yr Well the error means that your RecordHighlighter class either doesn't contain the getFieldUnencoded() function or it's private. So I'd start there. Given that getField doesn't work you probably have other issues with your RecordHighlighter class. It's not part of the API (or at least not the version I'm using). As a quick test you might try <?php echo nl2br( $fmrecord->getField('source_with_URL', 0))?> and see if you get your data. If the HTML is encoded you can always use html_entity_decode() to decode it.
August 18, 200817 yr Author Hi thanks for the reply. Do you know how I can find out more information about the RecordHighlighter class? Thanks Steve Well the error means that your RecordHighlighter class either doesn't contain the getFieldUnencoded() function or it's private. So I'd start there. Given that getField doesn't work you probably have other issues with your RecordHighlighter class. It's not part of the API (or at least not the version I'm using). As a quick test you might try <?php echo nl2br( $fmrecord->getField('source_with_URL', 0))?> and see if you get your data. If the HTML is encoded you can always use html_entity_decode() to decode it.
August 19, 200817 yr Other than looking at the code not really. If you didn't write it I'm guessing it's from the site assistant so you might check there. I don't use the site assistant so I'm afraid I can't really help you out with it.
August 19, 200817 yr Author OK I've found this code in another include file fmview.php. /* This a wrapper for a FileMaker_Record that checks the find request and encloses any data matching the request in a span marked with the 'found' class. The css files define the look of found items. */ class RecordHighlighter { private $_findRequest; private $_record; function __construct($record, $cgi) { $this->_record = $record; // if there's a stored find request save a reference $find = $cgi->get('storedfindrequest'); if (isset($find)) $this->_findRequest = $find; else $this->_findRequest = NULL; } function getRelatedSet($relationName) { return $this->_record->getRelatedSet($relationName); } function getField($fieldname, $repetition = 0) { // call the inherited version to get the data $result = $this->_record->getField($fieldname, $repetition); $field = $this->_record->getLayout()->getField($fieldname); if(isset($this->_findRequest[$fieldname]) && is_array($this->_findRequest[$fieldname])){ $stringValue = implode("n", $this->_findRequest[$fieldname]); $this->_findRequest[$fieldname] = $stringValue; } if ($this->_findRequest != NULL && !FileMaker::isError($field)) { // if the find request is for a field specified highlight the target if (isset($this->_findRequest[$fieldname]) && strlen($this->_findRequest[$fieldname]) && $field->getResult() != 'date' && $field->getResult() != 'timestamp') { $target = $this->_findRequest[$fieldname]; $replace = "" . $target . ""; $result = str_replace($target, $replace, stripslashes($result)); } } return $result; } function getRecordId() { return $this->_record->getRecordId(); } }; // RecordHighlighter If anyone can explain how this works and what changes are necessary to allow me to use getFieldUnencoded on my recordlist.php page that would be great. Thanks, Steve
August 20, 200817 yr re how it works. The class is designed to emphasize with tags the found text from a search. It doesn't contain a "getFieldUnencoded()" function so in order for it to be used you'll need to write it. You might try doing a find in files in your project to see if getFieldUnencoded() does exist somewhere. Unless you really need to have your found text "highlighted" just scrap the class and use the API's record class. If you need to encode or decode your result just use php's built in functions for that (see previous post for link) Based on the code you posted getField() should however return the field's value regardless of which class you call it from. use print_r($fmrecord); to make sure you've got a Filemaker_Record object and that it contains the correct data.
September 8, 200817 yr Author Thanks everyone I got this working now. Here's the code that allowed me to use getFieldUnencoded: <?php $recnum = 1; foreach($records as $key => $record) { $recid = $record->getRecordId(); ?>
Create an account or sign in to comment