Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Base Directories and Publishing Locations

It seems to me that in many development environments, the local web server, on which the editors will be previewing their work, cannot be set up so that the site is in the root directory.  It will be at least one level below the root.  However, when the site is published to the live site, it will be at the root level.

Consider a site called foo, which will be at the domain potato.org.  The editors will be previewing the site at localhost/potato/index.html, which the live site will be at www.potato.org/index.html.

Now consider the situation in which you have two sub-sections of the site, "ries" and "mashed," and two installatins of CityDesk so that two editors can maintain these sub-sections independently.  You now have this:

www.potato.org/fries and www.potato.org/mashed  on the live site and:

locahost/potato/fries and localhost/potato/mashed on the local web server for previewing.

Now consider that the editor of the "fries" section wants to link to the "mashed" section.  If these were in the same CityDesk instance, then we would use the Magic Name, and all would be great.  But we have split the two sections into two instances on CityDesk (perhaps the two editors are in two different cities).

The question becomes: how does one create the link?  The problem is that the base directory differs with the publiching location!  It is at the root on the live site and one-level below the root on the preview site.

My solution (and I have seen others use this) is to create a variable called "homeURL" and preface the link with this:  <a href="{$.homeURL$}/mashed/yummy.html">click here</a>

And then if I am publishing to the live site I define homeURL = "" and if I am publishing locally I define homeURL = "potato"

This is really, really bad.  Why?  Because the editors now have to REMEMBER to redefine "homeURL" before publishing to the live site.  And what happens if they forget?  Their site is BROKEN!  And the chances are that they will forget to test the site!  They should not have to preview the live site AFTER they have previewed their work on the local site!

The only way my small brain has figured out a way to fix this is to always generate PHP pages to do post processing.  Perhaps I should call it preprocessing, because it establishes the base directory before serving up the page to the web visitor.

But what does this mean?  This adds the requirement that every web server has PHP installed.  This is not acceptable in my book. 

I am hoping that someone has a better solution.  I have considered coding in a Server-Side include into all templates grabs a file that establishes the base directory.  That file would be placed into every directory by hand (ie., outside of CityDesk).  In this way, it would not be over-written by CityDesk.  I would place different versions on the localhost and on the live server.

Hopefully in the next version of CityDesk the page generator will have more intelligence and can adjust itself based on the publishing location.

Even better, there is already a solution that I am overlooking.

Joel Finkel
Monday, May 05, 2003

What's wrong with "/fries/index.htm"

This is an absolute link built out from the domain.

www.marktaw.com
Monday, May 05, 2003

I just use the "http://..." address for both. I figure that the other site, although belonging to the same company, is out of my control and therefore I treat it like other external sites.

When I'm publishing to localhost I've usually got internet access, so clicking on the links still works. It also gives me a heads-up if the other guy has published locally but hasn't published his site to the public server yet, so I don't upload my site with broken links.

It also makes it obvious which links are not part of my CityDesk site, which helps future maintainers a little bit.

Darren Collins
Monday, May 05, 2003

*  Recent Topics

*  Fog Creek Home