HiveBrain v1.2.0
Get Started
← Back to all entries
patternphpMinor

The first major app CMS writen

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
thecmsmajorappfirstwriten

Problem

I am looking for a suggestion or advises about some code I have written. I build an online application about 3 month ago the app registers new buildings including description names and so on. The app works perfectly and does what it suppose to. While working on it I was constantly learning and improving my skills. I did include the internal CSS as it was designed specifically for this page but I also used external one as well. I used a lot of ajax, php, and js. I looked at many tutorial and articles while working on this.
My main question is

1) some suggestion toward improving the structure

2) is the code similar to something that in a real world in real companies programmer write.
3) Is it good for someone who just started it career and the first major web app he is written.
Here is a sample file again it all working I do not want you to go thru every line just suggestions.

```


/ demo styles /
fieldset { border:0; }

select {
width: 400px;
}

a.ggg{
color: #003366;
font-size: x-large;
font-family: Monotype Corsiva;
}

a.gg{
color: #003366;
font-size: medium;
font-family: Monotype Corsiva;
}

.darkbg{
background:#ddd !important;
}

#status{ font-family:Arial; padding:5px; }

ul#files{ list-style:none; padding:0; margin:0; }
ul#files li{ margin-bottom:2px; width:200px; float:left; }
ul#files li img{ max-width:180px; max-height:150px; }
.success{ background:#FFCC99; border:1px solid #FF9933; }
.error{ background:#f0c6c3; border:1px solid #cc6622; }
#button { padding: .5em 1em; text-decoration: none; }
#effect { width: 700px; height: 200px; padding: 0.4em; position: relative; }
#effect h3 { margin: 0; padding: 0.4em; text-align: center; }

















$(f

Solution

When it comes down to improving the structure there's reallly 2 ways to go about it when it comes to the client side.

I can see that your loading your CSS Directly within the page, this can be a pro when it comes to loading speeds, but with today's internet speeds that's practically nothing.

I would separate each entity of the site, entities being:

  • CSS



  • Javascript



And i would use link / script tag's to include this to your page, the reason for this is that if you have multiple pages you would have to copy and paste each block of a css and javascript to that page, and then when you make a small change you would have edit lots of files.

When it comes to PHP, you seem to be doing the same thing, directly typing the code into the main page, as stated before this would cause issues with updates, so place it within a template and include it:

You can make your templates a lot more flexible this way, here's how i think your layout should look:


    
    
        
            
            
            
                
                    
                
                
                    
                
            
        
        
    


Also another major issue that I see is that your code is extremely invalid, you should google W3C Validator and validate your html

Code Snippets

<!DOCTYPE html>
<html>
    <?php require('templates/head.php'); ?>
    <body>
        <div class="wrapper">
            <?php require('templates/header.php'); ?>
            <?php require('templates/menu.php'); ?>
            <div id="container">
                <div id="main">
                    <?php require('templates/content/main.php'); ?>
                </div>
                <div id="main">
                    <?php require('templates/content/sidebar.php'); ?>
                </div>
            </div>
        </div>
        <?php require('templates/content/footer'); ?>
    </body>
</html>

Context

StackExchange Code Review Q#1724, answer score: 2

Revisions (0)

No revisions yet.