Monday, April 27, 2009

Movable Type Asset Tags

Asset Tag Input : Convert text field to Radio Buttons or checkboxes


Movable Type assets (images, docs, pdfs, xls, virtually any document) can be uploaded and managed through MT's dashboard. A label, description, and tag(s) can be assigned. I use the asset tags to selectively list assets on my blog's index pages. The problem is that it is hard to remember what is the exact wording of the tag (capitalized, plural, etc.), because tags are entered in a text form. And I certainly don't want my clients to have to remember which tags to use.

Here's the Original "Edit Asset" Panel




Same Panel with Radio Buttons




This limits the choice of asset tags, but then that is the point. I had to edit two MT system files to accomplish this. Fortunately, it's the same change in both files.

Edit These Files (backup first)


mt/tmpl/cms/dialog/asset_options.tmpl
mt/tmpl/cms/dialog/edit_asset.tmpl

Replace the Following Code (same in both files)


<mtapp:setting id="tags" label="<__trans phrase=" tags="">"
label_class="text-top">
<div class="textarea-wrapper">
<input name="tags" id="tags" class="full-width" value="<$mt:var name=" tags="" escape="html">" autocomplete="off" />
</div>
</mtapp:setting>


With the new code


<mtapp:setting
id="tags"
label="<__trans phrase="Select one tag from the list below.">"
label_class="text-top">
<ul class="edit-tag-radio">
<li><label><input type="radio" name="tags" id="tags" value="minutes"<mt:if name="tags" eq="minutes"> checked="checked"</mt:if> /> <__trans phrase="Meeting Minutes"></label></li>
<li><label><input type="radio" name="tags" id="tags" value="financial"<mt:if name="tags" eq="financial"> checked="checked"</mt:if> /> <__trans phrase="Financials"></label></li>
<li><label><input type="radio" name="tags" id="tags" value="welcome-document"<mt:if name="tags" eq="welcome-document"> checked="checked"</mt:if> /> <__trans phrase="Welcome Documents"></label></li>
<li><label><input type="radio" name="tags" id="tags" value="image"<mt:if name="tags" eq="image"> checked="checked"</mt:if> /> <__trans phrase="Image"></label></li>
</ul>
</mtapp:setting>


Note that the "value" and "__trans phrase" values are particular to your project. Also more options can be added.

Prefer a Checkbox?


If you prefer a checkbox list instead of radio (allowing multiple selections), just use type="checkbox".

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home