Website - Separate file for text
@DJEB Super easy. DO NOT INSTALL a content management system such as wordpress. That will just make things much more difficult. Coding for wordpress without PHP knowledge is next to impossible. And coding with PHP knowledge you realise just how terribly written it is.
This can be done simply either with SSI (server side includes) or PHP (or any other language that your web host supports). I'll use PHP for this example.
1. First off, the file extension of the main page needs to be .php. and the website needs to be hosted on a server that has PHP. So we will call it index.php.
2. Create another directory called "pages" and in that directory have all of your text files. These can be any extension, either .htm or .txt will be fine - it will show as HTML code either way. The pages can be "home.htm", "contact.htm" and "whatever.htm".
So in index.php have all of your menus and the main template.
At the top of your index.php file put this:
<?php$page = (isset($_GET['page'])) ? $_GET['page'] : 'home'; //If there is no page specified, the default will be 'home'.$pageUrl = 'pages/'. $page .'.htm'; ?>
Then, in index.php, wherever you want the content to be shown, do this:
<?php include_once($pageUrl); ?>
So this means that the only file you need to do all the templating is "index.php". So anyone viewing your page will by default be taken to the home page. When you are linking to another page, the link needs to be like this:
<a href="index.php?page=contact">Contact Us</a>
If you need any help getting that implemented, just ask (but tag me as I don't tend to check replies otherwise)
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now