Renaming Files on Publish
In traditional web development, establishing a filenaming convention and
directory structure is a substantial task. From the end user perspective,
filenames directly translate into the URLs that content is accessed
through. For developers, the convention provides a key method of defining
how a site may grow and it serves as the “road map” for them to understand how
the content is organized. Additionally, issues such as namespace
collisions and intelligibility of names are a factor. With a CMS many of
these concerns are alleviated because the CMS provides its own methods for
interacting with and growing the content, as well as keeping track of unique
names and other variables. In CrownPeak CMS, there are several ways to
specify this information, running the gamut from completely manual systems to
dynamic systems that can enforce specified logic for filename and path creation.
Default method The default method is to use the existing
label and location for the Asset. The Asset’s label becomes the filename,
and the folder path the Asset is in becomes the path to the published
file. Any spaces in the label or folder path are translated into their
hexadecimal equivalent to allow for proper publishing and linking.
Publishing Properties method The filename and path info
for an asset can be specified using the Publishing Properties. Using this
interface, the path info and filename can be manually
entered.
Separate rows are provided for configuring HTML and Media
publishing information. The HTML rows define publishing information for
the page itself, while the Media rows define where the attached media files
(i.e., a GIF or JPEG) will be published. Upon saving any configuration, a
new blank row will be added to the HTML and Media sections. This allows an
Asset to have several different publishing configurations.
If the Asset
has an associated template, there will be an option to specify a Layout
File. The Layout File allows a single Asset to be published in multiple
formats, with a Layout File corresponding to each desired format. This
could be as simple as allowing for the publishing of a normally formatted HTML
file and a “printer friendly” HTML file, or as complex as publishing an Asset in
HTML, XML, and WML formats, all to separate servers.
Filename Template method The third method of specifying
the filename and path info is through the filename.asp template file. By
setting the _cmsPublishPath value in this file, you can programmatically define
the path and filename. These values may be set for the various Layout
Files as well by analyzing the value of _cmsLayout. Of all the methods,
this is the most robust and flexible in terms of the end result. One
reason for using the Filename template would be to ensure that a filename is
unique by appending the Asset’s CMS ID to it.
Choosing a filenaming scheme Based on the above methods,
there are several different ways of defining a filenaming scheme. Any
scheme must balance the needs of end user intelligibility with ease of
growth/maintenance while ensuring that there are no namespace collisions.
Most implemented schemes rely on a combination of the above methods. For
example, a site’s homepage would likely have it’s publishing information
specified in the Publishing Properties interface (because it will always publish
to index.html), while supporting pages (which will vary in number as site
content grows) would utilize the Filename template method to dynamically
generate a name.
|