Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Adding Content Sections without Breaking Code

    Not sure where to begin on my latest problem...

    Here goes...

    So I am wrapping up my first website, which is a "portal" on Small-Business.

    It was completely hand-coded, and doesn't use anything like WordPress. (Yuck!)

    Everything has been working great, except for this "tiny* little problem I discovered last week...

    All of my effort over the last year has been spent on making my website more "interactive" by adding features like User Accounts, Private Messaging, Friending, Subscriptions, Profiles, etc.

    All of this works great, except I realized a few weeks ago that I didn't do a very good job planning what to do when my CONTENT grows!!!

    Currently, all Articles are stored in MySQL.

    And here is my current "Pretty URL" scheme...
    http://local.debbie/articles/postage-meters-can-save-you-money
    http://local.debbie/articles/consider-becoming-an-s-corporation
    http://local.debbie/articles/when-to-hire-a-consultant


    Once I get 20-30 Articles, this structure will be a real drag for Users, because no one will want to scroll down through 30 Articles in my Article Index Page!

    It would be nice to be able to add Sections "on-the-fly" and not break all of my Article-related scripts along the way.

    Something like this seems more scalable while keeping my "Pretty URL's"...
    http://local.debbie/articles/finance/postage-meters-can-save-you-money
    http://local.debbie/articles/legal/consider-becoming-an-s-corporation
    http://local.debbie/articles/management/when-to-hire-a-consultant

    Or like this...

    http://local.debbie/finance/postage-meters-can-save-you-money
    http://local.debbie/legal/consider-becoming-an-s-corporation
    http://local.debbie/management/when-to-hire-a-consultant


    I feel fairly comfortable with mod_rewrite's, but I think my problem is much more complex for this reason...

    In my "articles" directory, I have several scripts that relate to an Article...

    - "add_comment.php"
    - "edit_comment.php"
    - "rate_article.php"
    - "report_comment.php"
    - "join_thread.php"


    In those scripts, I have code that is looking for the Article in the "article" directory like this...

    PHP Code:
        // ******************
        // Set Return Path.    *
        // ******************
        
    if (empty($_SESSION['articleReturnPath'])){
            
    // Store Path to Original Article.
            
    $_SESSION['articleReturnPath'] = (isset($_SESSION['returnToPage']) ? $_SESSION['returnToPage'] : "/articles/$slug");
        } 
    PHP Code:
        // Change Redirect from "article.php" to "rate_this_article.php"
        
    $_SESSION['returnToPage'] = "/articles/rate-this-article/$slug"

    Both of those code snippets are EXTREMELY INFLEXIBLE, because if I add "finance" and "operations" directories, then - as I see it - I would need to have TWO SCRIPTS to support the different Article locations?!

    Not sure if I am making sense, and I PRAY that I don't have to re-write my entire website because of this seemingly innocent oversite on how my Articles will be structured...

    Any idea of where to begin on this problem???

    Thanks,


    Debbie

  • #2
    Regular Coder nomanic's Avatar
    Join Date
    Feb 2009
    Location
    United Kingdom
    Posts
    255
    Thanks
    9
    Thanked 33 Times in 33 Posts
    could you have an article appear in 2 locations?

    for example the article about terms exists in legal directory, however is accessible through articles folder and legal folder?

    www.mysite.com/articles/stuff_about_terms.html
    www.mysite.com/legal/stuff_about_terms.html

    for listing you can split it into legal etc, so its all subdivided
    but always reference it through articles directory?
    both links would take you to the same article though?
    does that make sense? does that help?
    <DmncAtrny> I will write on a huge cement block "BY ACCEPTING THIS BRICK THROUGH YOUR WINDOW, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE INSTALLATION OF THIS BRICK INTO YOUR BUILDING."
    <DmncAtrny> And then hurl it through the window of a Sony officer
    <DmncAtrny> and run like hell

    Portfolio, Tutorials - http://www.nomanic.biz/


  •  

    Posting Permissions

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