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");

Sunday, 5 May 2013

DOMdocument and the Pound Sign (£)

There's something odd about the way that PHP's DOMdocument function behaves if your HTML includes a pound sign, ie alt-0163 (which is pretty likely if you live here in the UK, where it is the currency symbol).

Attempts at replacing the symbol got me nowhere - echoing the file, it appeared to be coded as Â£, but str_replace using this string didn't do anything.

Eventually, I forensically examined the output character by character, and discovered that I needed to do a replace on
£

and from then on, everything was easy!