Help with file inclusion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kamatsu
Forum Newbie
Posts: 2
Joined: Sat Apr 01, 2006 5:39 am

Help with file inclusion

Post by kamatsu »

Hello, I am currently working on a simple content management system for my website and hopefully others.

I have a series of files (html) and I previously have simply been include() ing them into my design dynamically..

Suppose I had this file:

Code: Select all

Hello World!
And I added this:

Code: Select all

Hello World ~~~IncludeFile:otherfiletoinclude.php~~~
I would then like to be able to read the file, and include the file specified there, so the eventual output would be:

Code: Select all

Hello World   This is the contents of otherfiletoinclude.php
At first glance this didn't seem to daunting, I used regular expressions to find the ~ indicated area, and replaced them with <?php include('blah'); ?>. However I would now like to pass this to the PHP interpreter, as if it were a seperate file, so that the include statements are processed. Do i have to write it to a temporary file to do this?

Blah, may be hard to understand, sorry bout that.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I don't see the point of this at all.. why not let php handle this? No use creating a completely new syntax..

Code: Select all

Hello World <?php include 'otherfiletoinclude.php'; ?>


Make sure you change the extension to .html to .php or add the addHandler .html to be interpreted
kamatsu
Forum Newbie
Posts: 2
Joined: Sat Apr 01, 2006 5:39 am

well

Post by kamatsu »

The reason that is not feasible is that the user will be using a tinyMCE richtext editor to create content, and if i want them to include a module (e.g an RSS aggregator or poll or something) within a content page, it is irrational to expect them to be able to go and open up the HTML source and type some PHP code in, the user will be typing the ~~~ tags in and i would like my CMS to convert those: it shouldn't be too difficult.
Post Reply