How to put PHP Includes in a page

6 posts by 4 authors in: Forums > CMS Builder
Last Post: March 26, 2010   (RSS)

By (Deleted User) - March 25, 2010

We want to put a php include on the articles pages (it is like an "ending" we want to use for several articles and after having created the include file, and put it into a wysiwyg field, when rendered, it changes the references to the external file as follows: <[/#0000ff]p[/#800000]>[/#0000ff]<!--p include("en/includes/states-closing.php")-->[/#008000]</[/#0000ff]p[/#800000]>[/#0000ff]</[/#0000ff]p[/#800000]>[/#0000ff]

instead of:
[/#0000ff]<p>
<?php include("en/includes/states-closing.php");?>
</p>[/#0000ff]

It replaces the <?php for <!--p and [/#0000ff]It doesn't show the content of the external page.

How can we do it?

Thank you.

Re: [rneube] How to put PHP Includes in a page

By Jason - March 25, 2010

Hi,

It's usually not a good idea to add php code directly into the editor. The easiest way to do this is to go directly into your viewer file and add the php include directly into there.

Let me know if that works for you.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [rneube] How to put PHP Includes in a page

By InHouse - March 25, 2010

Just musing aloud here, but could your content be moved to a non WYSIWYG text box? You might find it easier to embed parsable code in there.

Alternately, you could scan through your content at rendering time and insert your included code after N-number of paragraphs/linebreaks.

$0.02 worth.

Jayme

Re: [rneube] How to put PHP Includes in a page

By Dave - March 26, 2010

Hi rneube,

We don't recommend allowing php code in the wysiwyg and neither do the developers of tinymce ([url http://wiki.moxiecode.com/index.php/TinyMCE:FAQ#TinyMCE_strips_away_or_alters_my_server-side_code]link[/url]) and if you enable this it will mean anyone with any access to your CMS (or even access to a form that adds content to your CMS) will be able to run *any* php code they want and basically have full access to your server and databases, but...

If you really want to do it, there's a tinymce plugin here that allows it:
http://sourceforge.net/tracker/index.php?func=detail&aid=2859676&group_id=103281&atid=738747

Another way to do it is to use placeholders (eg: #banner#, #include1#, etc) and replace those with the php code in your viewers. It would take more setup time initially but have the benefit of letting you change what #banner# included (or any other placeholder) without having to update a whole bunch of hard coded php code.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] How to put PHP Includes in a page

By (Deleted User) - March 26, 2010

Thank you very much! excellent ideas (both posts). I will try them now.

Thanks again!