Templating website; if not Joomla... how? php?

I have run a website for over 10 years which runs a different way. That is the website URL links are run by a php script with the ending url.



basically I have 1 single template html file that has an empty “center page” table. There would be a $PutInBody text in this center page. The script would then import the page at the end of the “?” into the center page. The reason I had this done (This is like 10 years old); I don’t know HTML and rely on MS Expression Web 3 (was frontpage 2003) WYSIWYG editior. Back then websites were run with all duplicated pages with content. Which would mean if you wanted to edit the layout you would have to edit all pages as well to reflect the change.

To prevent this and make it easier for me, that script was built so I can have 1 template page and import the pages (and not needing frames, or iframes). Approx 1 year ago a guy on a forum introduced to me the frightening truth about this script and how adding text (coding) we could (and proved) could obtain my database information, passwords, httacess content, downloading from my own server, uploading virus’s, etc) all from that script. HUGE HUGE SECURITY HOLE ! ! ! !

I have been in contact with him for the passed year and he said he would help me with constructing the website (how to handle the pages) with the new website. The time has come for this and thru a bunch of emails, he’s been pointing me out to various things to do… He eventually realized (I did mention it many times to him) that I rely on a WYSIWYG editor; don’t know html and just want 1 template to import pages into for ease of administrating…

He said to use a rewriting technique that tell the server that it wants however this would be a problem. Since the actual images would be a php insert for each image, that means if I went to edit the page in the editor, I could not see it and since I don’t know html, i couldn’t just build my graphical pages… To solve this he introduced me to something called JOOMLA that he claims would solve all my problems.

I took a look at joomla but it appears this would be even worse! Seems you have to construct a new template over again and use joomla to store the content into a database, create and execute menu’s, etc… I see no way to just use it for template purposes… I have my own menu image bars that I have links to other pages.

All I want to do is this.

  1. use 1 html template file (with REGULAR html and images; no coding where images should import, etc) WYSIWYG friendly html being able to view images in layout with ease.
  2. Have 1 part in the template where to import plain html pages into
  3. Having Normal URL for the pages on the website.

I THOUGHT Joomla was the answer but seems this isn’t so since it appears I need to start over, store content in database, create pages in joomla and adhere to joomla’s way of handling pages, menu’s, etc.


You can accomplish this with a pretty small amount of PHP. Try this, assuming your web site’s document root is in /www/site/public_html:

  1. Create an .htaccess file in your site root (/www/site/public_html/.htaccess) containing the following lines:

php_value auto_prepend_file /www/site/public_html/prepend.php
php_value auto_prepend_file /www/site/public_html/append.php

  1. Create the prepend script in the document root (/www/site/public_html/prepend.php):


  1. Create the append script in the document root (/www/site/public_html/append.php):

$__content = ob_get_clean();
require 'layout.html';

  1. Create your layout.php file in the doc root as well (/www/site/public_html/layout.php):

<?php echo $__content; ?>

Then for the rest of your site, just create your “plugged in” pages as before via your WYSIWYG editor, but name them with a .php extension. so if your index.php looked like this:


Then the resulting page will look like this to the rest of the world when it’s requested:


You’ll want to make sure that you don’t include the “outer” portion of the html in those pages (html, body, etc) but I assume you’ve got that handled already.

This isn’t a perfect solution, but if you don’t have any other dynamic content to worry about then I imagine this should get you by.

Wow, this just might be the answer I have been searching for! :slight_smile:

Would this mean that layout.html is just regular layout (theme for the whole site). with a “<?php echo $__content; ?>” instead of the $PutItBody text the old script was looking for. Then the insert pages are just plain html format pages (without the opening/closing Meta/body/html tags) ?

could regular www.domain.com/url/folder/ work? (using index.php as the insert page without having to include “index.php” in the url?

And would the image paths would be workable no matter where the pages reside on the server? (ie. images and insert pages are not in root with the Layout.html file [which would be in root] ) ?

Thanks :slight_smile:

You definetely want to go with a CMS, whether that is Joomla, Drupal or WordPress or other. They all effectively separate content from templates which is what your after, but they do it much better than the solution you currentlyhave in place.

It does mean:

  1. Learning curve (Drupal and Joomla especially take a while to master are quite complex)
  2. Importing static HTML content files into the Joomla pages database table

Re-mapping the old URI paths in Joomla is a two way street. On one hand you might opt to go for a SEF/SEO URI on the other, you might prefer to stay with the existing layout, in which case, that would probably result in more work.

Personally I would suggest Joomla :slight_smile:



It should, unless your apache config only looks for index.htm and index.html…in which case you’ll need to get it re-configured to also use index.php as a DirectoryIndex.

Yeah images can be anywhere. the prepend/append/layout stuff will only kick in when a PHP script is requested (actually, when ANY php script is requested). everything else (images, css, javascript, plain html) will just get served up as-is.

This technique should give you exactly what you asked for, and nothing more…it really is pretty inflexible, and it won’t scale out in terms of features without an awful lot of extra code. If you plan on expanding the site to offer more features (contact forms, forum, polls, user registration/auth, file uploads, etc), then Like PCSpectra I’d also suggest installing and getting to know an existing CMS/blog platform. The time you invest in doing so will pay dividends the next time you build a site.

Oops, copy/paste typo in that .htaccess I mentioned. Should be:

php_value auto_prepend_file /www/site/public_html/prepend.php
php_value auto_append_file /www/site/public_html/append.php