SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Expanding Content without Breaking My Code?!

    My website is about finished, but this past weekend something occurred to me that I fear will break all of the code I have written!!

    The majority of my website revolves around Articles, and right now I have this simple structure...
    Code:
    WebRoot (directory)
    	articles (directory)
    		index.php
    		article.php
    		add_comment.php
    		edit_comment.php
    		rate_article.php
    Currently, all of my Articles are accessed from this URL...

    http://local.debbie/articles/


    The problem is that as more and more Articles are added, there will be a need to break things up into sections, just like a newspaper (e.g. Current Events, World, Local, Sports, Money, Entertainment, etc.)


    Unfortunately, all of the files in my "articles" directory contain code like this...

    PHP Code:
            $_SESSION['articleReturnPath'] = "/articles/$slug"
    PHP Code:
            <li><a href="#here">Make a Comment</a></li>
            <li><a href="<?php echo "/articles/join-article-thread/$slug"?>">Subscribe to Thread</a></li>
            <li><a href="<?php echo "/articles/rate-this-article/$slug"?>">Rate this Article</a></li>
    PHP Code:
            $_SESSION['returnToPage'] = "/articles/edit-comment/$slug/$user/$commentID"

    So, since all of my scripts which support Articles revolve around this paradigm, I fear I am screwed if I add new sections or sub-divide things...

    What would I need to do if I wanted to switch from URL's like this....

    http://local.debbie/articles/postage-meters-can-save-you-money
    http://local.debbie/articles/consider-becoming-an-s-corp
    http://local.debbie/articles/when-to-hire-a-consultant


    To something like either this...
    http://local.debbie/articles/finance/postage-meters-can-save-you-money
    http://local.debbie/articles/legal/consider-becoming-an-s-corp
    http://local.debbie/articles/management/when-to-hire-a-consultant

    OR...

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




    Thanks,


    Debbie

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    If you are just looking at breaking it up at the navigation perspective for the user, then adding a column to your CMS table of "category" should be all that you need, perhaps a category table to maintain whether those categories are active or not. This will allow you to present your navigation in category form after modifying the queries used to populate it.

    While it might look nicer to have the category in the URL, it is definitely not required to manage your UI a little better.

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Does this problem relate more to mod_rewrite, or is it a PHP Coding issue, or is it an Architectural problem?

    Thanks,


    Debbie

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    If you feel that it is necessary to have your category in the URL, then it will include mod rewrite. Otherwise, i fyou are only looking at adding this to the UI, then yoiu are only looking at adding a column to a table, and some very minor PHP edits.


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
  •