Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Forget FX.php Write Native CDML direct in PHP code

Featured Replies

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

}



?>

 

  • 1 month later...
  • 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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.