Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    RetroSteve! My location

    Stephen Coates's Avatar
    Join Date
    Mar 2003
    Location
    Rotherham
    Posts
    2,187
    Downloads
    0
    Uploads
    0

    Website advice wanted

    I've finally updated my website a little bit:

    http://stevecoates.net

    I've wanted to put links to other interesting sites, so I added some on the right have side. There is also the old Navigation bar on the side.

    Firstly, is it possible to have the navigation and links bars all in one place and somehow distribute it over all pages? Kind of like how you would do it with frames (but not using frames). Currently its all in HTML but I wouldn't mind trying a bit of PHP. This would be to avoid updating each page with new links.

    All the pages are just static web pages. Nothing is served out from a database or similar. I would like to keep it database free as it is mostly just fixed content on the site.

    I would also appreciate a bit of design advice. It could do with a better layout and a better choice of font and colour scheme. Any suggestions?

    Thanks
    Stephen Coates

  2. #2
    Retro Addict Administrator
    My location

    Burger Time Champion, Sonic Champion Harrison's Avatar
    Join Date
    Dec 2002
    Location
    UK
    Posts
    16,654
    Blog Entries
    1
    Downloads
    6
    Uploads
    14
    Hi Steve,

    That is a great start to your newly updated site. It already looks nice and clean and easy to look around so don't add too much more to it. For example you don't actually need boxes around content all of the time, so as long as the different areas of the page are separate enough that the user can easily identify them individually, and what each is for (navigation, main body content, advert links, header etc) then you are fine.

    Regarding creating a way to distribute common content across all pages from one source, yes this is very easy to do using php. With php you are basically still creating html pages, but do make sure they are xhtml pages these days, and utilise css style sheets to format the page and avoid using any properties within html tags themselves.

    Firstly XHTML. All this actually means in its most basic description is standardisation of html syntax and formatting. With html 4 many sites might have upper case html code, which is not good as all browsers and other technologies accessing it won't always work with them. All must be lowercase. In addition all html tags much be closed. Again in html 4 a lot of people never bothered closing tags, so you might have found a paragraph < p > tag, but no < / p > tag. This has to be included now. And if you have single html tags that don't surround content then you close the main tag itself. For example < br / >. Hope that makes sense?

    I can help you with your site and coding structure as you build it if you would like?

    Site templates

    Creating a site template s is how you would put all common code into single files, and then call the rest of the site pages from it.

    Firstly we have a single page called index.php which the whole site will run from. This file contains all of the site design and layout, and within in contains placeholders that call the actual content to load into the positions from variables.

    When loading page content into the main index.php file we would use a variable and php include code.

    So your index page would contain the normal html code laying out the page. Then create each page/s content in separate files f.ex

    Code:
    pages/home.php
    pages/about.php
    pages/news.php
    Then in the body of your main index html page you can setup some php code to call these to load the content one into the page at the correct position. For this we would use the php include code.

    Code:
    </php include("page/home.php"); ?>
    However, that is only useful for a single hard coded page. To utilise loading all pages into the single template index.php page we would need to test for and retrieve a variable from the url. For example we could call the variable p and load pages by using index.php?p=about

    Firstly in the position on the page where we want each page's content to load, we would use a variable. So

    Code:
    </php include("$currentpage"); ?>
    Next we have to generate the page held in that variable from the url string. So at the top of the index.php file we can add some more php code to do this. Here is a very basic method to get you started.

    Code:
    <?php $currentpage = $p . ".php"; ?>
    This takes the p=pagename from the url ad automatically uses what it equals as the variable contents. And this code adds .php to the end of it and sets the $currentpage variable. So for example if the url was index.php?p=about, then this would make $currentpage = about.php and so it would then load this file into the include location within the index.php file where you place the include.

    If you have all your pages in a sub directory called pages then you would use

    Code:
    <?php $currentpage = "pages/" . $p . ".php"; ?>
    As you can see, php uses . as the concatenation operator to join strings together into a single variable.

    Hope that makes sense. This is just a very basic beginning. Try it out and once you get includes working I could introduce you to adding code needed for error checking, so the server will first test to see if the page called from the url string exists before loading it, so you don't get error pages. As well as other better methods of retrieving the variable from the url.

    Also I also always break the index page up even more, creating separate pages for each part of it, so I would have a navigation.php file in the template directory and this would just hold the navigation part of the page, which would then be loaded into the index.php page with an include. This allows the index.php page to contain just code and layout, and no content at all.

    Hope that all made sense?

    If you haven't played a classic game in years, it's never too late to start!


  3. #3
    RetroSteve! My location

    Stephen Coates's Avatar
    Join Date
    Mar 2003
    Location
    Rotherham
    Posts
    2,187
    Downloads
    0
    Uploads
    0
    Thanks Harrison. I thought you might be knowledgeable in this area.

    That's slightly baffling since I'm new to PHP, but I get the idea and will have a play in due course.

    I never realised you could close the <p> tag. I thought it just sat on its own .

  4. #4
    Retro Addict Administrator
    My location

    Burger Time Champion, Sonic Champion Harrison's Avatar
    Join Date
    Dec 2002
    Location
    UK
    Posts
    16,654
    Blog Entries
    1
    Downloads
    6
    Uploads
    14
    You can see where issues would arise when not closing tags though? If you have an opening tag, but no closing one, then how does the browser know when the influence that tag has is meant to end? Is the case of a paragraph <p> tag, html and browsers were always a bit forgiving with this and if they encountered another paragraph tag they assumed it would be the start of a new paragraph and the old one had ended. However, it isn't good coding or syntax practice.

    Which is why xhtml was invented; to standardise html coding and formatting to ensure it could be loaded by any software compliant.

    Same is true of php, as that is also a lot more forgiving than most other languages. Variables for example don't need to be declared, or a datatype set for them. You can just start using a variable and the php interpreter will just assume it exists and start using it. You can also chop and change what a variable has stored. Confusing for some programmers coming from other languages where you have to strictly declare a variable before using it.

    xhtml and php can be a bit confusing to begin with, but it is fairly easy to learn and understand. It's definitely my favourite language.

    If you haven't played a classic game in years, it's never too late to start!


  5. #5
    RetroSteve! My location

    Stephen Coates's Avatar
    Join Date
    Mar 2003
    Location
    Rotherham
    Posts
    2,187
    Downloads
    0
    Uploads
    0
    I see what you mean about not closing a tag.

    I just thought that, for example, a <p> on its own would tell the browser to start a new paragraph regardless of where one ends.

    So, for the PHP code, can I just put that in line with my current HTML code, or do I need to set anything up first?

    Previously I had done the webpages in Netscape Composer (probably version 4 ), but for this update I decided to modernise a bit and used KompoZer which has been recommended to me a fair bit.

  6. #6
    Retro Addict Administrator
    My location

    Burger Time Champion, Sonic Champion Harrison's Avatar
    Join Date
    Dec 2002
    Location
    UK
    Posts
    16,654
    Blog Entries
    1
    Downloads
    6
    Uploads
    14
    It's better to hand code, than rely on an editor that inserts and constructs its own code.

    A really good free editor is notepad++. It supports all known languages, colour coding it, and line numbering.

    You can insert php code wherever you want within your html file. You just need to wrap the PHP in the <?PHP ?> tags to tell the server where to parse it.

    If I have chance later I will knock you up a quick PHP file and attach it for you to look at and play around with.

    If you haven't played a classic game in years, it's never too late to start!


  7. #7
    RetroSteve! My location

    Stephen Coates's Avatar
    Join Date
    Mar 2003
    Location
    Rotherham
    Posts
    2,187
    Downloads
    0
    Uploads
    0
    a simple example file would be good to have a look at, thanks.

    Notepad++ is a nice editor. I have used it on Windows. Don't think it runs on Linux though. Gedit, which I use here does the same thing though.

  8. #8
    ELITE Staff Member
    My location

    Space Invaders Champion, Flash Sprint Champion, Seconds Of Madness Champion, BMX Park Champion Submeg's Avatar
    Join Date
    Jul 2004
    Location
    Adelaide, SA
    Posts
    2,666
    Blog Entries
    3
    Downloads
    0
    Uploads
    0
    If I had the time and drive, I would do my own coding for mine...but I would rather spend the time working on other projects!
    Check out my blog - submeg.com/

  9. #9
    Retro Addict Administrator
    My location

    Burger Time Champion, Sonic Champion Harrison's Avatar
    Join Date
    Dec 2002
    Location
    UK
    Posts
    16,654
    Blog Entries
    1
    Downloads
    6
    Uploads
    14
    That's the thing. If you know how to handcode it can be much faster, and the results are exactly what you want to achieve, plus you know the code only contains what it needs to, without any of the bloat webpage creators always add into the final webpage code. It also means if a website breaks you can normally work out why and get it back up again. Trying to fix a site created by a program can be next to impossible sometimes, as it can be really hard to untangle how the program built the site.

    This isn't the same as using something like Wordpress, Joomla or vBulletin. It would take years of coding to get anywhere close to what these projects can do, and they are mature enough to just use them. All I'm referring to is more basic websites/pages you would code yourself.

    If you haven't played a classic game in years, it's never too late to start!


  10. #10
    Retro Addict Administrator
    My location

    Burger Time Champion, Sonic Champion Harrison's Avatar
    Join Date
    Dec 2002
    Location
    UK
    Posts
    16,654
    Blog Entries
    1
    Downloads
    6
    Uploads
    14
    A basic example of some php within an xhtml webpage. I'm just showing the current time, and then loading the contents of another file into the page. Place both files in the same location and then load the index.php into the browser.

    Obviously you will need to run these from a server for the php to work.

    If you want to have your own local test server running to test php then download and install WAMP. It sets up an Apache server on your PC with PHP and MySQL already setup. You then just run WAMP and put your files into the WWW directory to run and test them. You access them by typing http://localhost/ into your browser.
    Attached Files Attached Files

    If you haven't played a classic game in years, it's never too late to start!


Similar Threads

  1. Humour The Website is down
    By Harrison in forum General Chat
    Replies: 1
    Last Post: 16th November 2010, 18:27
  2. MAME advice on CHD's
    By Bloodwych in forum Arcade
    Replies: 38
    Last Post: 8th June 2010, 14:14
  3. A500 Buying advice, please
    By Cortona in forum Buying and Selling
    Replies: 6
    Last Post: 8th July 2009, 23:29
  4. Basic A500 advice?
    By Fern in forum Hardware
    Replies: 5
    Last Post: 29th November 2008, 18:46
  5. Advice to get an Amiga for old games
    By Tiago in forum Amiga
    Replies: 10
    Last Post: 24th November 2008, 16:03

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright classicamiga.com