shortysbest Posted December 7, 2010 Share Posted December 7, 2010 I have a website that is completely hash based. It only ever loads one page the whole time you're on the site. The rest of the pages are loading in with ajax. What I am using to check for hash changes is $(window).hashchange( function (){}); and everytime the hash changes it loads the page that it tells it to based on whats in the hash. Now. This works perfectly fine when i just have one variable in the url that needs to load the page, however when i want to have a tabbed navigation inside of the first page that loads it either has to load the entire page again. (which would make this completely pointless if I kept it like this), or i cannot pass a url in the hash, (which wouldn't work because if you reload the page it wouldn't automatically go back to that tab and everything. So what I need is a better system in how i get pages through the hash. Okay to make it more clear as to what I am looking for I'll show some examples. example hash with only one page needing to be loaded. www.mysite.com/index.php#!/profile&id=1 This will load the php page called profile.php, with the users ID as number 1. now, when you click on a tab on the users page the url would look something like this: www.mysite.com/index.php#!/profile&id=1&tab=information This will load information.php into a div inside of the profile.php page without reloading the profile page. (Well I mean that's what i want it to do) Could anyone give me some direction in how I could accomplish this. Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/220886-hash-url-based-website-load-pages-with-multiple-variables-in-url-etc/ Share on other sites More sharing options...
shortysbest Posted December 7, 2010 Author Share Posted December 7, 2010 :-\ Quote Link to comment https://forums.phpfreaks.com/topic/220886-hash-url-based-website-load-pages-with-multiple-variables-in-url-etc/#findComment-1143843 Share on other sites More sharing options...
haku Posted December 7, 2010 Share Posted December 7, 2010 I'm not 100% sure if I understand your problem, but if I'm understanding it right, you can create a global for the current page, and a global for the current tab, and then check to see if the page or tab in the hash are different from the ones in the global. If they are, load the relevant page or tab, then store the new page or tab in the variable. Quote Link to comment https://forums.phpfreaks.com/topic/220886-hash-url-based-website-load-pages-with-multiple-variables-in-url-etc/#findComment-1144002 Share on other sites More sharing options...
shortysbest Posted December 7, 2010 Author Share Posted December 7, 2010 could you write some code to illustrate what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/220886-hash-url-based-website-load-pages-with-multiple-variables-in-url-etc/#findComment-1144006 Share on other sites More sharing options...
shortysbest Posted December 8, 2010 Author Share Posted December 8, 2010 nevermind, I got it working perfectly with your suggestion. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/220886-hash-url-based-website-load-pages-with-multiple-variables-in-url-etc/#findComment-1144594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.