Using include() and text files to dummy-proof a page - help!
Posted: Tue Dec 13, 2005 10:41 am
Hey everyone-
I'm trying to figure out a dummy-proof way to alter a PHP file so PHP-illiterate folks can change the content on it. The area in question is on the right side of this page: http://www.protectamericanfamilies.org. (Don't laugh, I hate the design too.)
Anyway, it's done in wordpress, and the right sidebar is really part of index.php. (Don't ask, just smile and nod.) The people who are writing the content on the site don't know any HTML or PHP at all, so I used a PHP include() script and a separate file called action_item.php that they could edit in order to change the content:
<?php include 'action_item.php';?>
<?php echo "$headertext";?>
<?php echo "$descriptiontext";?>
<a href="<?php echo "$actionpagelink";?>">
The action_item.php file is basically a series of variables like $headertext, $description, etc. that they can edit in the Wordpress dashboard... like so:
/*Title of current action item goes between single quotes*/
$headertext = 'La la la';
/*Place description text of current action between single quotes*/
$descriptiontext= 'blah blah blah';
and so on.
I very pointedly told them to put their text between the single quotes, add a backslash before any apostrophes, etc. Yet they still keep on screwing up the site by forgetting to close the quotes, forgetting to put a backslash before apostrophes, or directly dumping text from Word (so smart quotes show up, which means if they actually remember to do the backslash, the backslash itself shows up along with the smart quote). Go figure.
Anyway, I'm trying to figure out an even more foolproof way for them to change the right side text. Basically, there will be 3 text files - each one will have the corresponding header, description, and link - and then somehow get those text files in as variables into another file.
Would I still use an include() function, or will that not work if they're .txt files? I'm certainly no expert at PHP, so any advice is needed.
I'm trying to figure out a dummy-proof way to alter a PHP file so PHP-illiterate folks can change the content on it. The area in question is on the right side of this page: http://www.protectamericanfamilies.org. (Don't laugh, I hate the design too.)
Anyway, it's done in wordpress, and the right sidebar is really part of index.php. (Don't ask, just smile and nod.) The people who are writing the content on the site don't know any HTML or PHP at all, so I used a PHP include() script and a separate file called action_item.php that they could edit in order to change the content:
<?php include 'action_item.php';?>
<?php echo "$headertext";?>
<?php echo "$descriptiontext";?>
<a href="<?php echo "$actionpagelink";?>">
The action_item.php file is basically a series of variables like $headertext, $description, etc. that they can edit in the Wordpress dashboard... like so:
/*Title of current action item goes between single quotes*/
$headertext = 'La la la';
/*Place description text of current action between single quotes*/
$descriptiontext= 'blah blah blah';
and so on.
I very pointedly told them to put their text between the single quotes, add a backslash before any apostrophes, etc. Yet they still keep on screwing up the site by forgetting to close the quotes, forgetting to put a backslash before apostrophes, or directly dumping text from Word (so smart quotes show up, which means if they actually remember to do the backslash, the backslash itself shows up along with the smart quote). Go figure.
Anyway, I'm trying to figure out an even more foolproof way for them to change the right side text. Basically, there will be 3 text files - each one will have the corresponding header, description, and link - and then somehow get those text files in as variables into another file.
Would I still use an include() function, or will that not work if they're .txt files? I'm certainly no expert at PHP, so any advice is needed.