Jump to content

Re-developing my old messy site from scratch and the methods & practices I should use


hedgehog90

Recommended Posts

Hi,

 

I have a games site called GPStudios.com

I paid to have it built in 2009, but as you can see, it's looking a bit ropey these days compared to most other sites.

Since having it built , I have made many alterations to the site, and gradually learnt a lot of html and php along the way.

 

I make games myself, I do all the coding and all the graphics, so I feel quite confident that I can design all the assets of my site with relative ease. I've been using Dreamweaver for years now and I can now quite easily design a page of my own using php, http, javascript and mySQl. My only weakness is getting to grips with css, but I'm working on it.

 

I want to redesign the site from the bottom up, ditch the old design and create something completely new.

I will obviously use certain elements of the old site (much like I re use functions/engines/frameworks in all my games), but the site design is SUCH a mess that I don't think it would be wise to tidy it up. It's too far gone IMO.

 

So, this is my rather broad question... I would like to know where I should start. What methods should I use? My site is currently made up of mostly .php files. Is this appropriate nowadays?

 

 

I have a attached a few files to show you generally how the site is written.

Because every page is largely the same, it uses a lot of includes. Even on a page with unique content, it is often included as a separate php (eg homepage_popular). Unfortunately, this makes it difficult to preview the site in the dreamweaver design view.

Also, all the functions for the site are contained within a single functions.class.php file, which I was once told was very bad practice. Is it?

 

I'd like to know generally a method or a practice I should use.

When every page more or less uses the same template, is repeating the same div tags and includes necessary? Is there a better way of repeating myself? For instance, if I wanted for some reason to not have a header on my site, this would require me to change every single page.

 

 

My current site has been a victim to php injection also, so I'd like to know exactly how I can prevent this happening in the new site.

 

I'm not interested in designing it for multiple screen sizes, because most Flash games aren't really made for mobile devices. I think a 950/1000 px width static container is all I need.

 

I am genuinely focussed on redesigning my site, and if it means I have to spend several months of weekends working on it and learning about stuff then so be it.

I don't want to pay anyone else to do it, I want it to be 100% my own creation.

index.php

functions.class.php

homepage_popular.php

Link to comment
Share on other sites

My site is currently made up of mostly .php files. Is this appropriate nowadays?

 

Yes it is.

 

Also, all the functions for the site are contained within a single functions.class.php file, which I was once told was very bad practice. Is it?

 

Well I assume not all functions are required for all requests. So dividing the functions into an appropriate file and then only including the files from which you will be using the functions will consume a lot less memory then you are now.

 

You can do the same thing with classes, for example all db related functionality could be put inside a Database class. Tweet related functionality inside a Twitter class for example. Also it's advised not to use the mysql_* functions anymore but instead the mysqli_* functions.

 

When every page more or less uses the same template, is repeating the same div tags and includes necessary? Is there a better way of repeating myself? For instance, if I wanted for some reason to not have a header on my site, this would require me to change every single page.

 

You could take a look at Twig which allows you to create a template with blocks. It allows you then afterwards to extend the template and re-define/extend the previously defined blocks. For example if you had a template like:

 

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <title>{% block title}My Title{% endblock %}</title>
  {% block css %}
  <link href="css/screen.css" type="text/css">
  {% endblock %}
</head>
<body>
  
  {% block header %}
    <div id="header">
      <img src="img/logo.jpg">
    </div>
  {% endblock %}
  
  {% block js %}
  <script src="js/jquery.js"></script>
  {% endblock %}
</body>
</html>

 

Removing the header would be as simple as:

 

{% extend "base.twig" %}

{% block header %}{% endblock %}

 

Adding extra code to the header would be as simple as:

 

{% extend "base.twig" %}

{% block header %}
  {{ parent() }}
  <div id="subtitle">
    My Subtitle
  </div>
{% endblock %}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.