Results 11 to 20 of 27
-
27 Feb 2012 @ 15.01 Er...I'm not sure what you mean there.
So adding a dot makes it possible to modify the url, sort of?
It's just a way of keeping things organised. There are some small technical differences between subdomains and simple folders -- such as how cookies can be set, and whether you get another DNS lookup -- but basically you're just using them for convenience.
In particular, a subdomain is cheaper than running a completely separate domain (which would incur a registrar fee).
The "multisite" setup is especially "tidy", because you can keep all the settings separate. It's like having a separate account.
-
29 Feb 2012 @ 21.02 What about site navigation, how do you avoid having to rename the links?
-
1 Mar 2012 @ 09.10 Wherever practical, make all your links relative. For example:
- Good: "/articles/jam/raspberry"
- Bad: "dev.domain.com/articles/jam/raspberry"
(If you're seriously into performance, you can even insert links using a function that automatically creates the shortest possible URL!)
This works well within your HTML code, but sometimes in your application code (e.g. PHP) you might need full URLs. You can construct these with a PHP function.
For example, on my site, a full URL in PHP could be set like this:
$site is an object that I've already instantiated. It's domain() method returns the domain part of the URL (e.g. "http://www.domain.com/"). I can supply complete code if you like.Code:$URL = $site->domain() . "/articles/jam/raspberry";
Last edited by Mike Hopley; 1 Mar 2012 at @ 09.43.
-
1 Mar 2012 @ 21.50 How many kilobits do you think you have saved?
(If you're seriously into performance, you can even insert links using a function that automatically creates the shortest possible URL!)
That is what I thought, then you could browse your site as if it were live yeah?
/articles/jam/raspberry
How do you set up your localhost enviroment, do you use Wamp?
Yeah I would be interested to see how it works and if I could apply myself
I can supply complete code if you like.
Thanks
-
2 Mar 2012 @ 09.29 Not many. It's the sort of thing that Yahoo would do. It would mainly be useful on pages with long lists of links.
Yes, exactly.
That is what I thought, then you could browse your site as if it were live yeah?
Yes. I have four copies of my site:
How do you set up your localhost enviroment, do you use Wamp?
- Localhost, for whatever I'm currently working on.
- A development site on the server.
- A staging site on the server (I don't use this much).
- The live site.
I use Mercurial, a version control system, to manage the files. In practice, I almost always treat Localhost as the "central" repository, and push changes out to the remote repositories on dev, stage, or live.
Bear in mind this is just what works for me. I imagine there are better implementations from, say, a PHP framework like CakePHP.
Yeah I would be interested to see how it works and if I could apply myself
Thanks
I've redacted some directory names.
Code:class Site { // Resolves between dev, stage, and live sites function branch() { switch (htmlentities(dirname(__FILE__), ENT_QUOTES)) { case "/home/live_user/public_html": $branch = "live"; break; case "/home/stage_user/public_html": $branch = "stage"; break; case "/home/dev_user/public_html": $branch = "dev"; break; case "C:\\local\\path_to_website\\public_html": $branch = "local"; break; default: die(); } return $branch; } function domain() { switch ($this->branch()) { case "dev": case "stage": $root = "http://www.".$this->branch().".badmintonbible.com/"; break; case "live": $root = "http://www.badmintonbible.com/"; break; case "local": $root = "http://localhost/"; break; default: die(); } return $root; } function web_root() { switch ($this->branch()) { case "dev": $root = "/home/dev_user/public_html/"; break; case "stage": $root = "/home/stage_user/public_html/"; break; case "live": $root = "/home/live_user/public_html/"; break; case "local": $root = "C:\\local\\path_to_website\\public_html""; break; default: die(); } return $root; } function bin_root() { switch ($this->branch()) { case "local": $root = "C:\\local\\path_to_website\\bin_directory""; break; case "dev": $root = "/home/dev_user/bin_directory/"; break; case "stage": $root = "/home/stage_user/bin_directory/"; break; case "live": $root = "/home/live_user/bin_directory/"; break; default: die(); } return $root; } function current_page() { $path = htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES); return $path; } function current_page_full() { $host = htmlentities($_SERVER['HTTP_HOST']); $path = "http://".$host.$this->current_page(); return $path; } } $site = new Site();Last edited by Mike Hopley; 2 Mar 2012 at @ 09.34.
-
23 Mar 2012 @ 19.02 Back tracking here:
Why is this?
The development and staging sites should probably be password-protected.
Thanks
-
24 Mar 2012 @ 08.29 You don't particularly want visitors and search engines discovering your development environment. It's possible that security won't be as thorough amongst other things.
-
-
-
26 Mar 2012 @ 14.39 In this case: none, seeing as you'd end up with more code than you have now. Was just pointing out that this a text book example. Actually you're almost using a factory implemetation, you're just using switch blocks in the class that defines your interface instead of implementing the logic in child classes. The factory pattern would start making sense if you had, say, differences in the implementation of the "current_page" function.



4Likes
LinkBack URL
About LinkBacks






Bit complexer, but a handy design pattern to know and a lovely place to practice.







Hello every one
Hi, I am new on this forum and saying hello.