Jump to content

Forget FX.php Write Native CDML direct in PHP code

This topic is 7426 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • 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:



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.



$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, 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 />


		In database: [FMP-CurrentDatabase]<br /> 

		Search field: [FMP-FindFieldItem] <br />

		for value: [FMP-FindValueItem] <br />

		using operator: [FMP-FindOpItem]<br />


	<br />

	Field data inside InlineAction: [FMP-field: fieldnamehere, Raw] <br />

	You can list all Field Names in current layout:<hr>


		[FMP-FieldName]<br />



<br />

Remember: You can also edit or create new records and send email using InlineActions.


<br />

Finally you can get all Field Names In Primary Database:<hr>


	[FMP-FieldName]<br />



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='',$path='FMPro?-db=', $action='&-view'){


	$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);


		  flock($fl, LOCK_UN);




	return $stat;




Link to comment
Share on other sites

  • 1 month later...

This topic is 7426 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.