| tero.co.uk | ||
One Page CMS (Content Management System)
I have written a very simple single page CMS in PHP which allows you to place comment tags in files
such as
1. Download the file onepagecms.php
2. Change the settings at the top
3. Upload the file to your web site
4. Visit the file in your web browser
5. Alter the files you want to edit <div id="leftcolumn"> <!--ONEPAGECMS-START-LEFT-COLUMN--> <p>This is the editable stuff in the left column</p> <!--ONEPAGECMS-END--> </div> <div id="rightcolumn"> <!--ONEPAGECMS-START-RIGHT-COLUMN--> <p>This is the editable stuff in the right column</p> <!--ONEPAGECMS-END--> </div>
6. Test the editor
7. Logging out
8. Create and insert include files <div id="menu"> <!--ONEPAGECMS-START-MENU--> <ul> <li class="home"><a href="index.html">Home</a> <li class="about"><a href="about.html">About</a> <li class="contact"><a href="contact.html">Contact</a> </ul> <!--ONEPAGECMS-END--> </div>
To tell One Page CMS that this is a include you will need to change the
variable at the top of onepagecms.php: Then inside the files where the include should appear, insert the new ONEPAGECMSINCLUDE comment. The START line should contain the file name of the include, in upper case, with no directory or file ending. The space between the ONEPAGECMSINCLUDE-START and ONEPAGECMSINCLUDE-END can be empty - it will be filled when the include file is saved. For example, the page below contains two include references and an editable main area: <html> <head> <title>About us</title> <body class="aboutpage"> <!--ONEPAGECMSINCLUDE-START-MENUINCLUDE--> <!--ONEPAGECMSINCLUDE-END--> <!--ONEPAGECMS-START-MAIN--> <h1>About us</h1> <p>This is a paragraph about us.</p> <!--ONEPAGECMS-END--> <!--ONEPAGECMSINCLUDE-START-FOOTERINCLUDE--> <!--ONEPAGECMSINCLUDE-END--> </body> </html> Some includes, especially menus, will be slightly different on each page. Usually the link to the current page will be highlighted. Although it's a bit of a hassle, this can be achieved only using CSS. If you give a class to the body tag of each page and a class to each menu link (as in the example above), you can use CSS like this:
body #menu ul li {background: white;} /*the default background*/
body.aboutpage #menu ul li.about {background: blue;} /*background of selected page*/
body.contactpage #menu ul li.contact {background: blue;} /*background of selected page*/
10. Skins for the look and feel
If you would like to contribute a new skin, please create your own onepagecmsskin/styles.css and then contact me. I will ask for a zip file and then review it and post it here. Please do not make any changes to the HTML inside onepagecms.php. All the design must be done using only CSS and accompanying images, which means you may have to think creatively about it. Please also prepare a thumbnail screenshot of 150x150 pixels and a bigger screenshot. You must also make sure that the FormLogin page is included in the design. Download a skin above to see how it can be done.
10. Customisations and other features Editor buttons
<script type="text/javascript">
tinyMCE.init ({
mode : 'specific_textareas',
editor_selector : 'editor',
theme : 'advanced',
theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,|,undo,redo',
theme_advanced_buttons2 : 'link,cleanup,|,bullist,numlist,|,code',
theme_advanced_buttons3 : '',
theme_advanced_buttons4 : ''});
</script>
Frequency of backups Using a login form Editing the page title <!--ONEPAGECMS-START-META--> <title>My page title</title> <meta name="keywords" content="my page keywords" /> <!--ONEPAGECMS-END-->
11. Troubleshooting
The username and password doesn't work: Usually, you should get a grey box
popup asking for your username and password when you visit One Page CMS. If it
absolutely refuses to accept your username and password, then PHP may be running in
CGI mode, where this kind of authentication won't work. Instead you can either use
.htaccess authentication
or use the FormLogin function at the bottom of onepagecms.php (instead of PhpAuthLogin),
such as Warning: mkdir() [function.mkdir]: Permission denied: This error occurs when One Page CMS tries to create the backups or images directory and can't. The parent directory needs to be writeable and executeable by everyone (or by the web server user). Warning: fopen(filename.html) [function.fopen]: failed to open stream: Permission denied: This error can happen when you try to save a file or image. You need to make sure the file or image is writeable as above. Warning: glob() [function.glob]: open_basedir restriction in effect.: This means that your web server has a very restrictive (or secure) setup and so One Page CMS won't be able to list files or edit files. You will need to ask your web host about this one.
It doesn't find or list my files: One Page CMS tries two different methods to find
the files you've set in $ALLOWEDFILES: the PHP glob function and then the UNIX find command.
If neither of these work, then you probably can't put a wildcard * in the file names for
$ALLOWEDFILES. Instead you'll have to list all the files separately in an array. So instead
of
Advanced editor doesn't work - shows up as a text area instead: For the advanced
TinyMCE editor to work, One Page CMS filters all its files, so your web server setup must
allow for URLs like onepagecms.php/EDITOR/jscripts/tiny_mce/tiny_mce.js. If this doesn't work
I'm not sure which server setting needs to be changed, but I'd be happy if someone
could tell me.
In the mean time, change back to the simple editor, or download and use your own copy of TinyMCE.
To do this, download it from the TinyMCE website, unzip it, and change
the line in One Page CMS which refers to the TinyMCE script, to something like:
Notice: Undefined index: REQUEST_URI...: This may happen in older versions or interesting installations of PHP, and may well be related to the error above. You could try turning down error reporting by changing the line towards the bottom of onepagecms.php to: error_reporting (E_WARNING); so it only reports warnings and errors and not notices.
Donations please |
||