Wednesday 28 January 2015

CMS made simple - problems with include, require, include_once, require_once

Using CMS made simple (1.1.11 and 1.1.12), I hit problems with php files that I was trying to "include" in a User-Defined Tag (UDT). When I tried to save a Template, I hit a blank page (or occasionally, pages complaining about File Not Found) rather than returning to the Admin pages.

Eventual solution:

Do NOT use cwd() etc for capturing relative paths - "cms made simple" (cmsms) redirects pages, so that you send it off to find a file with an address that ends \pages\phpfiles\myfile.php (where "pages" is the prime cmsms directory) you will hit complaints that it cannot find the file  \pages\phpfiles\admin\myfile.php

So if you need the UDT to "include" file a.php, and a.php pulls in b.php, then have a.php specify the path from there to the file b.php (if in the same directory, simply "include (b.php);'

And what path to the first file? Use your HOST's path

eg for my host

include("/home/users/[USER NAME]/html/[DOMAIN NAME]/[LOCAL FILE STRUCTURE]/thisFile.php");

No comments:

Post a Comment