Topic: PHP include files (SSI)

SimpleCMS lets you edit PHP server side include files. You can use the following PHP functions to include files such as a global header/footer for a website.

require()
require_once()
include()
include_once()

The system is able to detect includes in the current folder, sub folders and parent folders. For example:

<?php
require('header.php');
require('../includes/header.php');
require('/includes/header.php');
?>

The code must be formated as in the examples above - including brackets, single or double quotes and ending with a semi-colon.

--
Short URL http://smplc.ms/ssi

Re: PHP include files (SSI)

I have noticed it actually takes the include content and embeds it into the page - sort of defeats the purpose of having an include so that the change is made globally

Re: PHP include files (SSI)

Hi Rachel, it shouldn't do that. As you say it would defeat the point of having include files.

Which site / page is this happening on? Feel free to email the details to us.

Re: PHP include files (SSI)

Hi Simon, is there a reason why this won't work using the SimpleCMS system:

<?php include($_SERVER['DOCUMENT_ROOT'].'/inc/header.php'); ?>

I use this method because it references the file from the root of the server, therefore wherever the page exists, the include link is correct.  I can get your method to work, but this is only a relative link.  Another CMS I use is fine with these, any suggestions?

Mike

Re: PHP include files (SSI)

The system only recognises relative paths

Re: PHP include files (SSI)

Ok, thanks for that answer.  Any suggestions for how you would you manage include files in a website that has pages in multiple directories?  Or is the answer just not give them access to edit includes?

I ask because im currently using both SimpleCMS and SurrealCMS and im trying to way up which is best for a new project.  Iv had a few sleepless nights over it and taken a week drawing up a comparison chart of functionality (you might find of interest).   Surreal works on relative paths as well but is happy with those type of include.  They have improved dramatically in the last couple of months, but you'll be happy to hear, I think you guys still have the edge.

Re: PHP include files (SSI)

Hi Simon, are you guys working on this as we speak?  Its suddenly started picking up these includes now:
<?php include($_SERVER['DOCUMENT_ROOT'].'/inc/header.php'); ?>

Its not saving the published changes yet, but it is letting me edit the include section?  : )

Re: PHP include files (SSI)

Hi Mike, we haven't made any changes, I believe trying to use $_SERVER['DOCUMENT_ROOT'] still won't work.