Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 6 1 2 3 ... LastLast
Results 1 to 10 of 54
  1. #1
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Hi,

    Someone just absolutly slated one of my sites for being old fashioned and coded badly. I think they dont know what they're talking about.

    Can anyone comment on this code and tell me if its out of date or old fashioned or plainly just wrong?

    It is a basic site and not dynamic however several parts of it are puilled from php files such as the menu and the footer etc.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Heavy Cultivation Parts | Agricast</title>
    <meta name="keywords" content="Heavy Cultivation Parts, agricast" />
    <meta name="description" content="" />
    <meta name="copyright" content="Copyright © 2011 All Rights Reserved" />
    <meta name="author" content="" />
    <meta name="robots" content="index,follow" />
    <link rel="stylesheet" href="agricast.css" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="fadeslideshow.js">
    /***********************************************
    * Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
    ***********************************************/
    </script>
    <script type="text/javascript" src="fader.js"></script>
    <script type="text/javascript" src="iepngfix_tilebg.js"></script>
    </head>
    
    <body>
    <div class="container">
    <div class="header">
    <?php include 'google_search.php'; ?>
    </div>
    <div class="bottom">
        <div class="left_menu">
            <?php include 'main_menu_norm.php'; ?>
        </div>
        <div class="right">
            <div class="body_text">
            <div class="body_big">
            <strong>Refurbishing your cultivation kit is 100%
    tax refundable at a fraction of the cost!</strong>
    </div>
    
    <p>
    Agricast are specialists in sourcing Disc Blades, Press Rolls,
    Cambridge Rings, Shoulder Rings, Subsoil Legs,Wear Points
    and Tungsten parts direct from foundries.
    </p>
    <p>
    We search the world for the most competitive steel to contain
    costs, ordering in bulk, passing the saving Direct to our
    customers.
    </p>
    <p>
    <strong>For the most competitive prices and overnight delivery,
    simply phone James for your FREE Quote.</strong>
    </p>
            </div>
            <div class="animated_image_holder">
                <div class="image_spacer"></div>
                <div id="fadeshow1"></div>
            </div>
        </div>
        <div class="mid_clear">
    
        </div>
    </div>
    <div class="footer">
    <?php include 'footer.php'; ?>
    </div>
    </div>
    </body>
    </html>
    I'd welcome any comments, thanks.

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Without seeing what's in the other PHP files, it looks fine to me. It's different from what I do, for sure, but that's hardly the test for whether it's good or not. It's semantic XHTML, no tables where not necessary. The only thing I see is there are a lot of divs, and some of them may be able to be replaced by other means, which isn't that big a deal.

    My guess is you're the victim of an HTML5 snob. I use it for my designs, but it really comes down to preference. Don't worry about it, you're doing fine.
    medlington likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Thanks for the feedback Ronald I've now spoken to him and it turns out his only issue was that the header of the site wasnt a PHP file and so he had to edit text on a few different pages, normally Id do that bit as an include but this was such a small site I hadnt bothered. It was just the language he used in his email was so harsh and made out I hadnt got a clue what I was doing which made me doubt myself.

    Nice to hear a second opinoin though, thanks again

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    It's actually very "old-fashioned" to use includes for header/footer.

    Modern MVC-style templating goes from the outside in. So you'll have a page or wrapper template, then a body include inside that, and a router will determine what gets put inside what.

    It's kind of hart do explain, but the end result is that you don't have any duplicated html from page to page, and you're not using includes on every page to render your header and footer.

  6. #5
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Ah, thanks for that, so it turns out he was right and wrong at the same time.

    Would you advise doing that for a simple 10 page site though thats not dynamic? I'd implement something like that if I was creating a larger dynamic site.

    Do you find it is more time consuming to do it that way as you have to setup the router?

    Speaking of which do you have any links to info about creating a router as this is something Im not really aware of and want to get my coding up to speed?

    Thanks

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Thing is, that's the type of thing you create once and never have to do again. I don't have any links, unfortunately. But for a basic router, use a url structure like this:

    http://www.mysite.com/path/to/file <-- make sure not to inclue an extension (no ".php")

    Then use .htaccess to interpret that:

    .htaccess
    Code:
    RewriteRule (.*) /index.php?page=$1 [L, QSA]
    Then, build your index.php page router to interpret the "page" param:

    index.php
    PHP Code:
    <?php

    // Get the current directory
    $dir dirname(__FILE__);

    $pageDir $dir "/pages/";
    $viewDir $dir "/views/";

    // Get the requested page
    $page = isset($_GET["page"]) ? $_GET["page"] : "index";

    // Check if the file exists in my pages, if not set to index
    if (!file_exists($pageDir $page ".php")) $page "index";

    // Buffer the page contents
    ob_start();
    include(
    $pageDir $page ".php");
    $content ob_get_contents();
    ob_end_clean();

    // And wrap it all in your default view
    include($viewDir "html.php");

    ?>
    Then, you set up your folder structure with /controllers and /views in your root folder (along with index.php and .htaccess)

    Your /views/page.php file will look something like this:

    /views/html.php
    PHP Code:
    <html>
    <head>
    .... stuff
    </head>
    <body>
    ... more stuff

    <?=$content?>

    .... more stuff
    </body>
    </html>
    You could get even trickier with that if you want... like I said, this is a very simple MVC.

    Then, your /pages/index.php file will look like this:

    /pages/index.php
    PHP Code:
    <h1>This is my page!</h1>
    <
    p>This is my content!  Notice no includes and no styling!  Just my app here
    Granted... that's not the exact way you're supposed to use a controller (in cake terms, this is more of a page-view than a controller, actually), but it works.

    And that, my friend, is your first MVC! Minus the models, of course lol.

  8. #7
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Thanks for that, it certainly gives me something to think about. I do alot of work with Magento and it seems to behave like that so I definitly need to get my head around it.

    .htaccess is something that I need to swat up on!

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Magento is build on Zend, which is an MVC framework.

  10. #9
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by smoseley, post: 223368
    Thing is, that's the type of thing you create once and never have to do again. I don't have any links, unfortunately. But for a basic router, use a url structure like this:

    http://www.mysite.com/path/to/file <-- make sure not to inclue an extension (no ".php")

    Then use .htaccess to interpret that:

    .htaccess
    Code:
    RewriteRule (.*) /index.php?page=$1 [L, QSA]
    Then, build your index.php page router to interpret the "page" param:

    index.php
    PHP Code:
    <?php

    // Get the current directory
    $dir dirname(__FILE__);

    $pageDir $dir "/pages/";
    $viewDir $dir "/views/";

    // Get the requested page
    $page = isset($_GET["page"]) ? $_GET["page"] : "index";

    // Check if the file exists in my pages, if not set to index
    if (!file_exists($pageDir $page ".php")) $page "index";

    // Buffer the page contents
    ob_start();
    include(
    $pageDir $page ".php");
    $content ob_get_contents();
    ob_end_clean();

    // And wrap it all in your default view
    include($viewDir "html.php");

    ?>
    Then, you set up your folder structure with /controllers and /views in your root folder (along with index.php and .htaccess)

    Your /views/page.php file will look something like this:

    /views/html.php
    PHP Code:
    <html>
    <head>
    .... stuff
    </head>
    <body>
    ... more stuff

    <?=$content?>

    .... more stuff
    </body>
    </html>
    You could get even trickier with that if you want... like I said, this is a very simple MVC.

    Then, your /pages/index.php file will look like this:

    /pages/index.php
    PHP Code:
    <h1>This is my page!</h1>
    <
    p>This is my content!  Notice no includes and no styling!  Just my app here
    Granted... that's not the exact way you're supposed to use a controller (in cake terms, this is more of a page-view than a controller, actually), but it works.

    And that, my friend, is your first MVC! Minus the models, of course lol.
    I don't know why but im just not getting what your talking about... If you could find a link or a tutorial for this that would be awesome. I think I need to start thinking about this too. I've never used something like this before.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  11. #10
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by Andrew Yurlov, post: 223491
    I don't know why but im just not getting what your talking about... If you could find a link or a tutorial for this that would be awesome. I think I need to start thinking about this too. I've never used something like this before.
    I'm kinda lost too
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Page 1 of 6 1 2 3 ... LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:16 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com