iframe vs php (feature)

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
twc
Posts: 233
Joined: Fri Jun 18, 2010 12:25 am
Location: Netherlands

iframe vs php (feature)

Post by twc » Wed Nov 21, 2012 10:11 am

i realy miss php option, i love php scripts :D

The content and new pages are html, so if i want to add php i must make iframes :( realy sucks and dont work good.

maybe future release make html files to php ?

lett me no..............

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: iframe vs php (feature)

Post by cmb » Wed Nov 21, 2012 12:23 pm

Hi twc,

actually you can use PHP in the content (even on news pages since CMSimple_XH 1.5) via CMSimple scripting. As written in the linked article putting out anything directly is not possible (one has to use $output instead), and generally CMSimple scripting is somewhat clumsy. So alternatively one might better use the so called plugin call {{{PLUGIN:my_function(...);}}}. This has two benefits: the PHP code doesn't clutter the page contents, and the script is encapsulated in a function to avoid clashes with CMSimple's code. The latter is particularly important if the PHP script is not related to CMSimple, as CMSimple uses many global variables with short names, so one can easily overwrite one of these variables inadvertently.
twc wrote:so if i want to add php i must make iframes
Instead of <iframe src="./test.php"> you can try the following:

Code: Select all

#CMSimple ob_start(); include('./test.php'); $output = preg_replace('/'.chr(35).'CMSimple.*?'.chr(35).'/', ob_get_clean(), $c[$s]);#
This might work depending on the script. Complex standalone scripts (e.g. a gallery or guestbook script) will typically require an IFrame anyway.

Actually having PHP syntax (<?php ... ?>) on a page is probably not possible at all, as AFAIK it will be removed by the browser in design mode.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

twc
Posts: 233
Joined: Fri Jun 18, 2010 12:25 am
Location: Netherlands

Re: iframe vs php (feature)

Post by twc » Wed Nov 21, 2012 1:52 pm

did not work........

http://encode-explorer.siineiolekala.net/

cmb wrote:Hi twc,

actually you can use PHP in the content (even on news pages since CMSimple_XH 1.5) via CMSimple scripting. As written in the linked article putting out anything directly is not possible (one has to use $output instead), and generally CMSimple scripting is somewhat clumsy. So alternatively one might better use the so called plugin call {{{PLUGIN:my_function(...);}}}. This has two benefits: the PHP code doesn't clutter the page contents, and the script is encapsulated in a function to avoid clashes with CMSimple's code. The latter is particularly important if the PHP script is not related to CMSimple, as CMSimple uses many global variables with short names, so one can easily overwrite one of these variables inadvertently.
twc wrote:so if i want to add php i must make iframes
Instead of <iframe src="./test.php"> you can try the following:

Code: Select all

#CMSimple ob_start(); include('./test.php'); $output = preg_replace('/'.chr(35).'CMSimple.*?'.chr(35).'/', ob_get_clean(), $c[$s]);#
This might work depending on the script. Complex standalone scripts (e.g. a gallery or guestbook script) will typically require an IFrame anyway.

Actually having PHP syntax (<?php ... ?>) on a page is probably not possible at all, as AFAIK it will be removed by the browser in design mode.

Christoph

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: iframe vs php (feature)

Post by cmb » Wed Nov 21, 2012 2:50 pm

Hi twc,
twc wrote:did not work........
Well, ...
cmb wrote:Complex standalone scripts (e.g. a gallery or guestbook script) will typically require an IFrame anyway.
The encode-explorer emits a complete HTML document, so this can't work directly in a page. One has to use an IFrame for that. In this case I recommend the Wrapper plugin, which seems to work fine here (it resizes the height of the IFrame as needed).

Or you might use the CMSimple plugin WDir, which supports only a small subset of encode-explorer's features, but quite useful too.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply