Including other files into content files
From phpCMS
[edit] Including other files into content files
If the content of a page is static for its bigger part and only a smaller part is changing, it can be preferable to only modify/update the changing part and leave the static part untouched.
To achieve this, one could include the changing part "dynamically" into the page, i.e. its content file.
Another use could be on multilingual websites in pages where a part of the page is language-independent. In those cases, one could include the language-independent part into an otherwise language-dependent page, thereby avoiding having to rewrite the language-independent part for each language used.
To implement an include, phpCMS provides an appropriate include command:
Syntax:
<PHPCMS_INCLUDE "filename">
Example: content file example.html
{PROJECT} ./example.ini
{MENU} 00.01
{CONTENT}
Here comes the included content:
<PHPCMS_INCLUDE "/some/where/foobar.txt">
Text which is read via the include command is handled as if it was part of the content file, e.g. tags get replaced etc.
This should work with almost every filetype of phpCMS, (HTML) content files, text files, template files, and maybe also with menu files, menu templates, tag files etc.
Note:
phpCMS cannot resolve $home and $plugindir inside the <PHPCMS_INCLUDE "filename"> statement when used in a content file because these placeholders are only set after the complete content file including the included files have been red.
But if this include statement is used in a template file, resolving $home and $plugindir should work.
(See Operational sequence in phpCMS (Overview) for the order in which phpCMS creates an page output.
An included file can itself contain an include command so one can nest as many include file as needed.
One thing to keep in mind, however, is that phpCMS only checks the file date of the main content file (and not of the included files) to find out if the content file is newer than the version in the cache.
So if a file which is included via the include command into a content file is modified, and the main content file is left untouched, phpCMS will not recognize that and it will use the completely assembled page from the cache instead of re-generating it. That means that one has to clear the cache manually via the admin GUI backend to get the changed content after a change in the included file(s).
Based on an entry by "Ignatius" in the phpCMS support forum.
Main Page: User Documentation MainPage
« Previous Page: How to include third party php scripts | Top Page: How to work with phpCMS | Next Page: How to use PAX »

