Recently in Client Education Category

By default, assets are placed in the site root as defined in the publishing settings. For example, if the site root was http://beausmith.com/ then the asset image.gif would be uploaded to http://beausmith.com/image.gif.

There are two common ways to change this:

  1. Define a default upload destination folder.
  2. Hard code upload destination and hide it from the form.

Define a default upload destination folder

To pre-populate the folder where assets will be placed add this line to the top of MT_BASE/tmpl/cms/include/asset_upload.tmpl and replace “assets” with your preferred folder name:

<$mt:setvar name="extra_path" value="assets"$>

I use “assets” because this is the most generic word to describe all the things that could be placed in this folder: photos, video, documents etc.

Or the second way…

Hard code upload destination and hide it from the form

Open MT_BASE/tmpl/cms/include/asset_upload.tmpl and search for this code (from MT4.0, code from MT4.1.x has a big chunk of javascript in the middle of the second <mtapp:setting> block, but the javascript can safely be removed as well):

<mt:setvarblock name="upload_hint">
    <__trans phrase="_USAGE_UPLOAD" params="<$mt:var name="blog_name" escape="html"$>">
</mt:setvarblock>
<mtapp:setting
    id="folder"
    label_class="top-label"
    label="<__trans phrase="Upload Destination">"
    hint="<$mt:var name="upload_hint"$>"
    show_hint="1">
    <!-- <$mt:var name="blog_url" escape="html"$> -->
    <select name="site_path" onchange="setExtraPath(this)">
        <option value="1">&#60;<__trans phrase="Site Root">&#62;</option>
    <mt:if name="enable_archive_paths">
        <option value="0"<mt:if name="archive_path"> selected="selected"</mt:if>>&#60;<__trans phrase="Archive Root">&#62;</option>
    </mt:if>
    <mt:if name="extra_paths">
        <mt:loop name="extra_paths">
        <option value="<mt:if name="enable_archive_paths">0<mt:else>1</mt:if>" middle_path="<mt:var name="path" escape="html">"<mt:if name="selected"> selected="selected"</mt:if>><mt:var name="label" escape="html"></option>
        </mt:loop>
    </mt:if>
    </select>
    / <input name="extra_path" id="extra_path" value="<mt:var name="extra_path" escape="html">" />
</mtapp:setting>

Replace the code with this code which will set the upload destination to <Site Root>/assets/:

<input type="hidden" name="site_path" id="site_path" value="1" />
<input type="hidden" name="extra_path" id="extra_path" value="assets" />

The “Upload Destination” form elements should now be gone from the upload asset modal.

Note: There are other ways to do this in the Perl code. It’d be nice to just have config directives to handle this.

WTF is CGI-BIN MT MT CGI? BAH!

| No Comments

What the f*ck is cgi-bin mt mt cgi?

Apparently that doesn’t make sense Mr. Client.

So I updated his .htaccess file with this:

Redirect /admin http://www.domain.com/cgi-bin/mt/mt.cgi?blog_id=1

Now he points his browser to http://www.domain.com/admin and he is redirected to his blog in his MT install.

Then he decided he didn’t want to type, just click… but didn’t want a link to “admin” visible on his site… so I made an invisible one.

So just after the date that appears on every entry in his blog, we linked a non-breaking space to his install:

<a href="http://www.domain.com/cgi-bin/mt/mt.cgi?blog_id=1">&nbsp;</a>