2

I am trying to make a navigation bar on the left.

|   1   |
|   2   |
|   3   |

<a href="???" id="1"></a>
<a href="???" id="2"></a>
<a href="???" id="3"></a>

I was wondering how facebook does their left navigational bar because when you click Messages on their bar, it turns into www.facebook.com?sk=inbox.

How do you change ur main div changing your url? Do you put

<a href="?sk=inbox> 

but then I was wondering what the action was that changes the div?

Would I have to use $_Request['sk']?

Thanks

d.mc2
  • 1,129
  • 3
  • 16
  • 31
  • What do you mean by "change the main div"? Is it like the sublevel "other" that appears below "messages" in facebook? – bfavaretto Jul 07 '11 at 02:15
  • "Changing the main div" means like you know how ur newsfeed turns into ur inbox then turns into whatever else – d.mc2 Jul 07 '11 at 02:55

2 Answers2

4

I have done something similar to this before:

I had a class called navigation and in my main nav ul I had the following snippet:

    foreach($aAllPages as $key => $value){

        $sOutput .= '<li><a href="index.php?pageID='.$key.'">'.$value.'</a></li>'."\n";

    }

After I have started the function I set the following:

$pageManager = new PageManager();

        $aAllPages = $pageManager->getAllPages();

The page manager was the model name that had a function called getAllPages that processed the specific data from the DB

Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
3

If I understand you correctly, I think you are referring to how Facebook modifies the URL of the page while making an AJAX call to populate the main div of the page with the new content. If you notice in IE the URL will look like

http://www.facebook.com/#!/?sk=inbox

instead of

http://www.facebook.com/?sk=inbox

Facebook is taking advantage of HTML5 features for modifying the history state (https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history).

This SO post (http://stackoverflow.com/questions/5527617/using-html5-pushstate-in-ie9) points to a history plugin that will take advantage of the new HTML5 features as well as fall back gracefully to older browsers with hashchange functionality.

Jeremy Battle
  • 1,638
  • 13
  • 18
  • wait, so does this mean that when u click the Messages button, you actually travel to www.facebook.com/inbox.php <-- some made up URL, but b/c of the pushstate, it still shows as facebook.com except with a /?sk_inbox ? – d.mc2 Jul 07 '11 at 03:08
  • No, what you seem to be talking about is mod rewriting. What I am talking about is changing modifying browser history to replicate page loads that don't actually happen. Facebook is mainly loading their data via AJAX. The problem with having AJAX loading for main content is it breaks the use of the back button in the browser, history plugins replicate this functionality while allowing heavy use of AJAX. – Jeremy Battle Jul 07 '11 at 03:39