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.

PHP Alternative to CDML 'Break' encoding?

Featured Replies

I'm working through converting our CDML pages to PHP, and with CDML I am using the 'Break' encoding for properly displaying text field content that may contain paragraphs (eg. [FM-Field: myField, Break]). This allows for paragraphs in a FM text field to at least look like paragraphs on a web page, even if semantically they're not.

However, using PHP all I get is one large block of text, irrespective of how it was formatted in FileMaker. Now, I realise that this is normal behaviour, but how do I go about replicating the CDML Break encoding functionality with PHP? I thought about searching for hard returns and replacing them with a <p> tag, but can't seem to figure out how to do it.

Anyone done this before?

Cheers,

Kevin

  • Author

Apologies for replying to myself here, but I've come up with a solution that should work, but doesn't with FileMaker (the script relies on FX.php).

  

<?php 

			$string = chr(13);

			$text = ($value['description'][0]);

			$description = str_replace($string, "</p><p>", $text);

			echo	"<p>" . $description . "</p>";

			echo "</div>n";

		}

		?>

If I use similar code on a predefined block of text that has the odd hard return in it, it works beautifully. But when applied to FM output via FX.php (which is in turn via XML), it doesn't work. I'm guessing that either FM strips out hard returns before generating the XML output, or FX does it on receiving it. Either way I'm stumped again.

Anybody got any ideas?

Cheers,

Kevin

  • Author

Well, this is beginning to become a habit ...

Anyway, I've solved the issue and thought for the sake of thoroughness I'd detail the solution here. In the code in my previous post, I changed this: $string=chr(13); to this: $string=chr(10) . chr(10);, which now works. It seems that OS X may use ASCII 13 (carriage return) as a hard return, but FM6U on the same platform uses ASCII 10 (line feed) ...

Strictly speaking, there's no need for the extra chr(10), but it more closely replicates CDML's Break encoding by converting 2 consecutive hard returns to valid <p> tags, without putting in empty paragraphs (which it does if you only use one).

Cheers,

Kevin, with apologies for running my own thread!

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.