SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 56 of 56
  1. #51
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    <?php
        
    if (isset($_GET['article'])) {
     
                
    $articleFile $_GET['article'].'.php';
     
                if(
    file_exists($articleFile)) {

                        
    ob_start();
                        include(
    $articleFile);
                        
    $content ob_get_contents();
                        
    ob_end_clean();

                } else {
                        
    $title 'Article Not Found';
                        
    $content '';
                }
        } else {
                include(
    'default.php');
        }
    ?>

    PHP Code:

    <?php $title 'You are reading Article 1'?>

    <h2>Article 1</h2>
    <p>This is Article 1...</p>
    Much easier to work with.
    The only code I hate more than my own is everyone else's.

  2. #52
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    And how is it different t=from this never-ending beat of "You need a CMS!"??
    Lets say you have 1000 articles (1000 separate files). Well two years down the line you decide to redesign the site. Best case scenario says that the HTML will not need to change. Worst case scenario you will need to modify everyone of those files. Now, a CMS would have a single template that loads in the data regardless of 1 or 100000000 articles. So it would be a snap to change the HTML for all articles, without needing to touch 1000000 files. That is one major benefit of using a content management system of some kind, home grown or otherwise. Not to mention to grant someone the ability to create articles besides yourself means giving them access to the server using your method.
    The only code I hate more than my own is everyone else's.

  3. #53
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,762
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    The nice thing about php is there are 500 ways to skin a cat. IMO what you have is a simple, but solid solution to your problem. It's hard to say if it will meet all your needs in the future, but it gets you on the right path. Should you need to change how you do things in the future, it allows an easy upgrade path since the page titles and contents are stored in php variables. i.e. if you discovered you needed to switch to a CMS or something it would be easy to pull the contents of the different pages during migration.
    Some more questions...

    1.) Can I just name my articles by there natural names?

    TheEntrepreneurWhizKidMyth.html

    Who'sStealingYourBusiness.html

    EmployeesFromHell.html


    And how does/should the articles relate to how my website is laid out?

    For example, if "Who'sStealingYourBusiness.html" is under Business>>Small Business>>Entrepreneurs then do I need to take anything else in to account?

    I suppose this is where a database starts to come in to play, in that you can start storing "metadata" about your content. But at the same time, why not just create a directory structure that keeps all of my articles organized? (More complex is not always better!)

    What do you think?


    2.) What is the best way to organize my URL "clean"? (Dare I say, almost an SEO question?!)

    (This could be another thread in itself, but I got in trouble for that before!)

    Here are some URL's from the LA Times...

    w w w. latimes.com/news/obituaries/la-me-elizabeth-taylorlong-20110324,0,3017190,full.story]

    w w w. latimes.com/business/

    w w w. latimes.com/business/smallbusiness/

    w w w. latimes.com/business/la-fi-smallbiz-qa-20110321,0,841506.story



    Here are some URL's from USA Today...

    w w w. usatoday.com/money/smallbusiness/default.htm

    w w w. usatoday.com/money/workplace/2011-03-22-triangle-fire-remembered.htm?loc=interstitialskip

    w w w. usatoday.com/money/smallbusiness/columnist/abrams/2011-03-18-how-to-lose-a-client_N.htm?loc=interstitialskip



    I see lots of different approaches. Not sure which makes the most sense?!

    I guess I like a URL that looks like what I would find in my laptop's file manager (i.e. going from general to specific with a self-identifying filename).


    3.) Do I create "pretty" URL's using the Apache mod_rewrite file with regular expressions?


    4.) Can I start off with a directory structure for now, and later migrate to a database?


    Thanks,



    Debbie

  4. #54
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,762
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oddz View Post
    PHP Code:
    <?php
        
    if (isset($_GET['article'])) {
     
                
    $articleFile $_GET['article'].'.php';
     
                if(
    file_exists($articleFile)) {

                        
    ob_start();
                        include(
    $articleFile);
                        
    $content ob_get_contents();
                        
    ob_end_clean();

                } else {
                        
    $title 'Article Not Found';
                        
    $content '';
                }
        } else {
                include(
    'default.php');
        }
    ?>

    PHP Code:

    <?php $title 'You are reading Article 1'?>

    <h2>Article 1</h2>
    <p>This is Article 1...</p>
    Much easier to work with.
    Can you please explain your code?!


    Debbie

  5. #55
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    The only code I hate more than my own is everyone else's.

  6. #56
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just want to say, Debbie, you have some talented people here trying to help you out. Don't be too dismissive in the suggestions and approaches.


Bookmarks

Posting Permissions

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