February 4, 200421 yr Newbies If you have your FMPro database on the same machine as your PHP, give this PHP file a try. This single file shows how to incorporate CDML into PHP code directly. No more parsing FX.php arrays! Just write native CDML. Too good to be true? Try it out and you'll be a convert. You have to enter your own variables and change some of the PHP settings: $db $pass Also some of the CDML has to be customized to your setup: For example... [FMP-InlineAction: -db=dbnamehere.fp5, -lay=layoutnamehere, fieldnamehere={$_GET['x']}, -find] Note: this InlineAction shows how to incorporate PHP variables into your InlineAction find request. <?php $cdml_file_name = "CDMLOnTheFly.html"; $cdml_file_path = "/Applications/FileMaker Pro 6 Folder/cdml_format_files/$cdml_file_name"; $db = 'dbnamehere.fp5'; $pass = 'passwordhere'; $CDML = " Some data you can get outside of InlineActions: <br /> Time: [FMP-CurrentTime] <br /> Date: [FMP-CurrentDate] <br /> Day: [FMP-CurrentDay, Long] <br /> Username: [FMP-ClientUserName] <br /> Password: [FMP-ClientPassword] <br /> <br /> CDML things that don't work in this technique (use PHP directly):<br /> IP: [FMP-ClientIP] (always going to be 127.0.0.1, php's IP) <br /> Cookies (because it is PHP pretending to be a browser so there's no place to store the cookie) <br /><br /> Data accessed via InlineActions (database must have same password as primary): <br /> [FMP-InlineAction: -db=dbnamehere.fp5, -lay=layoutnamehere, fieldnamehere={$_GET['x']}, -find] Find request inside InlineAction: <br /> [FMP-CurrentFind] In database: [FMP-CurrentDatabase]<br /> Search field: [FMP-FindFieldItem] <br /> for value: [FMP-FindValueItem] <br /> using operator: [FMP-FindOpItem]<br /> [/FMP-CurrentFind] <br /> Field data inside InlineAction: [FMP-field: fieldnamehere, Raw] <br /> You can list all Field Names in current layout:<hr> [FMP-LayoutFields] [FMP-FieldName]<br /> [/FMP-LayoutFields] [/FMP-InlineAction] <br /> Remember: You can also edit or create new records and send email using InlineActions. <hr> <br /> Finally you can get all Field Names In Primary Database:<hr> [FMP-LayoutFields] [FMP-FieldName]<br /> [/FMP-LayoutFields] "; write_to_file ($CDML, $cdml_file_path); echo get_CDML_output ($db, $pass, $cdml_file_name); function get_CDML_output($db, $pass, $cdmlfile, $user='user', $port='8080',$server='127.0.0.1',$path='FMPro?-db=', $action='&-view'){ $cdmlfile='&-format='.$cdmlfile; $url_with_pass = "http://$user:$pass@$server:$port/$path$db$cdmlfile$action"; $ret = file_get_contents ($url_with_pass); return $ret; } function write_to_file ($data, $filepath) { if($fl = fopen($filepath, 'w+')){ if(flock($fl, LOCK_EX)){ fseek($fl, 0); ftruncate($fl, 0); $stat = fwrite($fl, $data); fflush($fl); flock($fl, LOCK_UN); fclose($fl); } } return $stat; } ?>
March 26, 200421 yr Author Newbies OK, FMP7 makes this useless except as an example to show you how you might write XSL in the same way and tell FMP XML to grab an XSL doc for processing on-the-fly. That exercise is left to the reader.
Create an account or sign in to comment