Jump to content

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

Recommended Posts

Posted

I normally use PHP includes to pull in filemaker data so it disguises the address bar link to the database.

So I normally do something like this...


include("http://db.domain.com:591/FMPro?-DB=TEST&-Lay=WEB&-Format=template.html&-FindAll");

To get filemaker data onto my page.

Then I thought if I rename my filemaker format file to .cdml and add the file type .cdml to be parsed as PHP in my .htaccess file on my main website, then I could use PHP code in format files.

Well it works!!

But it gets better...

You don't even need to add .cdml as a PHP parsed file type in .htaccess

Any PHP in the cdml format file gets parsed.

Though it gets parsed after the CDML has been parsed.

This discovery has just saved me so much time. What a technique as well!

No need to install PHP onto the filemaker unlimited computer.

I totally did not know that PHP would just parse any php code appearing in included files.

This was just a quick post to let you guys know of this.

I assume someone out there had already discovered this, but this makes the database driven pages of my site so much tidier.

Before I was having to pass loads of tokens from the include() to the cdml format page.

Not any more! I can access session data from the cdml format file.

Fantastic.

Hope this helps someone out.

Thanks

Batfastad

Posted

Also means you can do some really cool stuff...


<?php



$foundcount = [FMP-CurrentFoundCount];



?>

Because the CDML instruction gets parsed, and the result pasted in before the code reaches the PHP parser.

Just think of the possibilities!

Obviously not as powerful as using FX.php but this is a very handy thing to know.

Thanks

Batfastad

Posted

Hi, batfastad! Hmm... that's good to know that the CDML goes first and then the PHP 'cuz I would've guessed it the other way around. About PHP and includes, though, I think(?) PHP allows MOST extensions but not necessarily ALL extensions. Also, if you do not use the .php exension, your code may not be protected and could be viewed by others if it matters to you. Try calling on your include files directly thru a browser URL and see.

I read a comment in the online PHP manual where a user reconfigured the Apache httpd.conf file to disallow access for any particular extension you want. I liked that idea so did so for 1 of our servers here so that now, all .inc files are denied through apache (just like .htaccess files) but can still be used as includes. I chose ".inc" so that any language can use the include (.php, .pl, etc.) and it is protected. login/password scripts, especially can benefit from this kind of setup, but it is server-specific, however, so not using the .php extension is dangerous for us if we ever move our files to another "standard" server.

I am by no means expert, though, and I'm still learning both PHP and unix (haven't even fully gotten to .htaccess files yet), so I could be mistaken about some of this.

Thanx for the tip, though!!

--ST

Posted

If you call the cdml format file directly through the browser, then you can see both the CDML code and the PHP code because it's not being parsed by anything.

It just gets sent to the browser by the filemaker web companion.

If you do a CDML query in the address bar, then obviously the CDML in the format file gets parsed, but the PHP doesn't display as text.

However you can see the PHP code if you view the source.

To be honest I'm not too worried about this as by including the filemaker CDML query through PHP on our main hosted webspace it's not apparent where the data is coming from anyway.

I've found the PHP in format files thing very useful so far, as it can let me do mathematical calculations and access PHP variables in the CDML format file. Session data also works.

I know that you can use JavaScript but I've never been a fan of javascript. I'd rather do mathmatical stuff server side.

Check out .htaccess! There's some really cool things you can do there.

Thanks

Batfastad

This topic is 7281 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.