I think the site_url and homepage variables are a couple of my favorites in ExpressionEngine.
The other day—while putting the book together actually - I ran across another handy place to use the homepage variable - in the Weblog Path Settings.
Path Settings are where you tell EE where the Weblog URL, the Comments Page URL, the Search Results URL are for a given weblog. Some of these get defaulted when you create the weblog.
What happens to me quite often is - no matter how hard to I try to remember - I forget to change these paths after a site goes live. Then when, for example, someone uses the Search, the path of the link returned still has the “temporary” domain name in it. The link will still work, but it messes up your server logs and just doesn’t look as nice as getting the live URL in there. Or - I decide to rename “index.php” to something more semantic and then have to go find all the places where “index.php” is stored.
So - what I discovered I could do is use the homepage variable in those settings - and then they will inherit the change to the homepage and root URL setting automatically. So, for example, rather than having a Search Results URL setting of :
http://some.domain.here/index.php/template_group/template/
I can specify:
{homepage}/template_group/template/
Now when I change the “URL to the root directory of your site” and the “Name of your site’s index page” under Admin > System Preferences > General Configuration all those individual weblog paths will change as well.
One less thing to worry about when launching a site = well worth it.
Visit Train-ee.com for the latest in ExpressionEngine training designed with one goal in mind - to get you up to speed on ExpressionEngine® as quickly as possible.
The latest Train-ee Products:
The latest from the Train-ee blog:
January 18, 2008
I’m in the process of creating (what I consider to be) the best cms ever. At first, I had such a variable that I’d have to manually edit whenever I implemented the cms on a different site. I discovered, however, that I could let php do the work for me:
$website = $_SERVER[’SERVER_NAME’];
$path = str_replace(’/index.php’, ‘’, $_SERVER[’PHP_SELF’]);
if($path!=’’){$website=$website.$path;}
There may even be a faster way, but that’s what I do.
January 18, 2008
Intersting… I’m still torn between building on a staging server, and setting up the site on a live server. It can be rather tedious, pushing the design changes out to a production/remote server.
It sounds like you use a local environment then Michael, at least in some scenario cases?
I’m looking at using the Zend Core stack with the bundled Apache server, or xampp with Zend Core, but the Zend Core updates all the libraries in the stack, or so it sounds like.
Further it could be installed on many server types as the actual production server to keep things stable in both environments local staging and production.
January 18, 2008
I only have a local setup for testing & for putting the book code together.
Otherwise I really prefer to work directly on the production server.
I can see a more complex setup for certain situations (high traffic, eCommerce etc) but for the typical small business setup I think the staging arrangement is overkill and just adds too much hassle.
I jump between machines here in the office, and work remotely quite a bit. It’s all seamless when I’m just working off the live server.