Hi All,
I'm in the process of upgrading to MT 5. I'm doing the upgrade in a staging area which is a subdomain of my site. I'm taking advantage of the upgrade to clean things up and reduce the clutter that's accumulated over the years. To this end, I need to rearrange where images and other resources are stored. I want to make sure this works in the staging area before switching over to my production site. Because of this, I need the URLs in the blog entries to use the proper domain (http://staging.mysite.com or http://mysite.com). I thought I could update the URLs to something like "images/whatever.png." However, I can't find a macro for the domain name itself. is there one? If not, how are people handling this sort of thing?
TIA!
--
Regards,
Travis Spencer
Reported on Movable Type 5
Hi Travis,
If you're talking about creating URLs that reference images, then I think you should be able to use URLs that explicitly *don't* reference the domain.
So if there's a folder at the top level of your website called images and a file called header.jpg in it, you can use:
<img src="/images/header.jpg">
and that will work both on your staging server and in production.
If there's something more complicated going on that I'm not aware of and you really do need to include the domain of the site, then you should be able to use:
<mt:blogURL/>
And this will output the "root" URL of the blog, as you've defined it in Preferences->Publishing
Hope that helps...
-tony
Thanks, Tony, for the reply; however, using server-relative paths (e.g., "/images/...") will cause the links to not work in feeds. Also, <mt:blogURL> won't let me access a directory right below the root of the domain. I want to put all images for all my pages and blog posts (for all three of my blogs) in the same directory (i.e., "http://.../images" not "http://.../blog1/images" and "http://...blog2/images"). As a result, I'd have to do "<mt:blogURL>../images" which is tacky at best.
Any other ideas?
I understand the new MT5 has blog-level Custom Fields... I'm not on MT5 myself yet, so I can't vouch for this.
I've done a workaround because I needed blog-level custom fields in MT 4. Create a global template module, e.g. "Settings"
inside, you can put:
<mt:var name="ImageRoot" value="http://staging.domain.com"/>
Then, be sure to include this module wherever you need it, ideally in a spot that's already being included -- for instance, you could include it in a common Header template:
<mt:include module="Settings"/>
Come to think of it, since in your case you want the same value for all blogs, you could simply set the ImageRoot variable in a global header template, if you have one.
The approach I've mentioned came in handy when there were settings that actually changed from one blog to another. (Again, really just a hack workaround for the lack of Blog Custom Fields).
This is really akin to using #include or similar constructs in more formal languages. In MT, we're kind of trained to use includes for chunks of HTML, but it can be helpful to think of using them for code constructs or variables as well.
-tony
Your suggestion sounds like it will work, Tony, so I'll try that. If I hit any snags, I'll post back here.
Thanks for the help. It's much appreciated.
Thanks for sharing the great solution