View Full Version : Site # Pages +REP
iLogan
23-04-2011, 10:54 PM
Hiya guys,
I need some help (+REP of course!), you see how Habbox has like pages http://habbox.com/#/Home how do you make it so like /#/home generates home etc kinda hard to explain, any ideas?
Logan
You mean a redirect? So you type in www.habbox.com/home and it takes you to the URL www.habbox.com/#/home ?
EDIT: I don't think that's what you're on about lol, apologies if it's not I don't fully understand what you mean
Do you mean like...
http://www.domain.com/anything_here_you_want/home
and it takes you to the home page?
If so it's done by making / editing your .htaccess file and putting in something like this
RewriteEngine on
RewriteRule ^/([^/\.]+)/home/?$ /home.html [L]
Should work :s
I don't think the hash does anything at all, I've been typing in websites such as http://www.bt.com/#/ & http://www.youtube.com/#/. They all load the companies home pages!
Try it with yours if that's what your aiming for.
example: www.yourwebsiteurl.com/#/
Jack!
24-04-2011, 03:12 PM
I believe Habbox uses Ajax to load the pages in frames, But you could get the same effect by using PHPIncludes. (/index.php=home, /index.php=page etc)
iLogan
24-04-2011, 03:23 PM
+REP to all,
I believe Habbox uses Ajax to load the pages in frames, But you could get the same effect by using PHPIncludes. (/index.php=home, /index.php=page etc)
Yeah, I think that's it, do you have any good tutorials on php includes?
triston220
24-04-2011, 05:15 PM
+REP to all,
Yeah, I think that's it, do you have any good tutorials on php includes?
I think he means using the GET argument to load the correct page. For example:
<?PHP
if (isset($_GET['action'])){
if ($_GET['action'] == 'aboutus'){
Echo "We are a company dedicated to providing you with quality food at affordable prices.";
}else if ($_GET['action'] == 'products'){
Echo "Our product range:";
}
}
?>
To view these, you would navigate to: PAGENAME.php?action=aboutus or PAGENAME.php?action=products .
I hope I've helped.
Jack!
27-04-2011, 09:15 AM
I think he means using the GET argument to load the correct page. For example:
snip
To view these, you would navigate to: PAGENAME.php?action=aboutus or PAGENAME.php?action=products .
I hope I've helped.
No, I ment PHPincludes.
Chippiewill
03-05-2011, 08:56 PM
http://www.habboxforum.com/showthread.php?t=43037&page=1
Use the second method and you can dynamically choose which page to load using the doohickeys (Forgot their namess OK?!?!).
I think there's a good link for a JS one as well, I'll look for that also... brb.
Edit, found it, some reassembly required for it to work as you'd like:
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
HotelUser
04-05-2011, 11:52 AM
The contents of the URL past the hashtag (#) don't get sent to the webserver, and are only client side. Because of this Habbox is able to detect changes in the URL past # dynamically by checking for a change 10 times a second and when one's detected we use AJAX (.load() in jQuery to be specific) to grab the specified page and stick the contents in a div.
Habbox.com/#/page/variable/value/variable2/value2
works out to be
page.php?variable=value&variable2=value2
If we used mod rewrite in lieu of our Javascript clean urls spinoff you would have to reload the webpage each time you click a link which would mean widgets like the Habbox Live radio player wouldn't work.
How to load content dynamically using AJAX:
http://api.jquery.com/load/
Habbox use our own self written functions to accomplish hashtag navigation, but there are jQuery plugins available if you wanted to use one of them:
http://plugins.jquery.com/plugin-tags/hash
Razzage
20-05-2011, 10:45 AM
<?
if($_GET[page]){
// checks if the page your looking for exists if not displays error
if(!file_exists($_GET[page].".php")){
echo"<strong>Missing File: </strong>".$_GET[page].".php";
}else{
// includes the page so the url is ?page=pagename
include_once($_GET[page].".php");
}
}else{
// Change home.php to your homepage
include_once("home.php");
}
?>
aidant
24-05-2011, 11:19 AM
OK, heres some jquery to do that:
var pageDirectory = "page"; // the directory in which the pages are located
var returnID = "content"; // the id on the element in which you want the loaded page to go to
//Coded by Aidan Taylor - www.aidantaylor.net
$(document).ready(function(){
//get the hash
var hash = window.location.hash;
if (hash != ""){
//take off the #!/ from the hash
var hash = hash.split("#!/");
//page route
var page = "./"+pageDirectory+"/"+hash[0]+hash[1];
//load the page
$("#"+returnID).load(page);//get the page
}
$("a").click(function(e){ //do when link is clicked
//get the href from the link
var url = $(this).attr("href");
//take off the #!/
var url = url.split("#!/");
//page route
var page = "./"+pageDirectory+"/"+url[0]+url[1];
//load the page
$("#"+returnID).load(page);
});
});
Your links will need to be like this:
<a href="#!/page"></a>
this is so that google picks it up and puts it down as a permanent url, if its just the #/page then google picks it up as non-permanent.
You can also do things like this:
<a href="#!/page/hiii"></a>
this script will get the pages from the directory you put, e.g, if directory is page, and the page name is home, it the page like this ./page/page-name, and it will get the main index page e.g. index.php, index.html ect, unless you put in what the page extension is e.g: x!/page.html.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.