Use Variables in Control Panel Settings
Make the site launch process easier by using either the site_url or homepage variables in configuring Control Panel paths.
I think the site_url and homepage variables are a couple of my favorites in ExpressionEngine. I’ve found that you can actually use these in the EE Control Panel - wherever paths need to be specified. This includes:
- Weblog Path Settings
- File Upload Preferences
- Category Image URLs
Note that this approach doesn’t seem to work in
- Member Image (avitar, signature, photo) Preferences
Also - I’ve found that if you want to use the image resizer plugin it will not work with variables in the file upload preferences.
Why would you want to use variables in these spots?
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 variables 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.
With some paths -like category images - you won’t want the “index.php” in there since you are referring to an image and not a template. In that case you can use site_url instead:
{site_url}images/uploads/category_accessories_150.jpg
Variables in Control Panel path settings == one less thing to worry about when launching a site == well worth it.
Category Navigation






by Steven Hambleton
Date: Friday, August 1st, 2008
Comment: #1
I wonder why it’s not in the CP as standard?