SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Switching Modes

  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Switching Modes

    I've learned enough PHP and MySQL to make a basic CMS. In fact, I have several CMS sites with geography or politics as themes, with bread crumbs-type navigation links at the tops of the pages. For example, they display World > North America > United States > Arizona on the page at http://www.geosymbols.org/world/na/usa/az/

    The navigation links are derived from a table with political entities listed in a parent-child relationship. I also use my databases to select and display the appropriate style sheets.

    I'm now developing alternate classification schemes with various themes, like ecology and politics. Below are examples of what the navigation links might look like on those sites:

    North America > United States > Southwest > Arizona
    Corporate West > North America > United States > Arizona

    So now I'm trying to figure out a way to implement two or more schemes on the same website. For example, visitors might view North America > U.S. > Arizona as a default, with two other choices, Nature and Politics. If they click the Nature link, button, or whatever, the style sheet would change, and the navigation links would change to North America > U.S. > Southwest > Arizona. Of course, they would have to remain in Nature mode even after clicking a link to another page - unless they decide to again choose another mode.

    Can this be done, and how? Ideally, I'd like to do it in such a way that only one mode is "running in the background." In other words, if a visitor chooses Political Mode, there are no invisible Default Mode or Nature Mode scripts running in the background, eating up file size or bandwidth.

    Thanks for any tips.

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)
    What about maintaining that in the url links?

    so a link off of a nature page to say, arizona, you append &cat=nature to the url

    /arizona/index.php?cat=nature

    Youd detect that up with $_GET['cat'] on the recieving page.

    2)
    if not the easiest way is probably in a cookie. Every page scans the cookie to see if its set and displays an appropriate view/css file

    3)
    else read up on sessions in PHP

    Either way you are trying to "maintain state", if you will pardon the pun.
    isempty()

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paulyG
    1)
    What about maintaining that in the url links?

    so a link off of a nature page to say, arizona, you append &cat=nature to the url

    /arizona/index.php?cat=nature

    Youd detect that up with $_GET['cat'] on the recieving page.

    2)
    if not the easiest way is probably in a cookie. Every page scans the cookie to see if its set and displays an appropriate view/css file

    3)
    else read up on sessions in PHP

    Either way you are trying to "maintain state", if you will pardon the pun.
    Thanks for the tips. The first one looked a little complex at first, but at second glance I'm intrigued. That could come in useful for a number of things.

    I did some quick research on cookies and sessions, and it sounds like sessions are actually the simplest. Plus, visitors might be less nervous if they know I'm not collecting cookes.

    Anyway, I just got a sessions script working, so I'm going to try to refine it now. Thanks again.


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
  •