Using MTML, you can sort assets by label in an entry context like this:
<mt:EntryAssets sort_by="label">
<!-- asset content here -->
</mt:EntryAssets>
However on the Edit Entry screen the filename for each asset is listed, but the assets are not sorted by filename.
The following steps will update the Edit Entry/Page screen to list assets by asset label…
Three App Templates to Edit
$MT_HOME/tmpl/cms/edit_entry.tmpl
Update the template that produces the Edit Entry/Page screen.
Line 491:
<mt:var name="asset_name">
Change to:
<mt:var name="asset_label"> [<mt:var name="asset_name">]
$MT_HOME/lib/MT/CMS/Entry.pm
Update the script that collects the assets in the sidebar of the Edit Entry/Page screen.
Line 191:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_thumb => $asset->thumbnail_url(Width=>100)};
Change to:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_label => $asset->label, asset_thumb => $asset->thumbnail_url(Width=>100)};
Line 193:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name};
Change to:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_label => $asset->label};
Line 201:
my $asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name};
Change to:
my $asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_label => $asset->label};
Line 210:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_thumb => $asset->thumbnail_url(Width=>100)};
Change to:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_label => $asset->label, asset_thumb => $asset->thumbnail_url(Width=>100)};
Line 212:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name};
Change to:
$asset_1 = {asset_id => $asset->id, asset_name => $asset->file_name, asset_label => $asset->label};
Line 217: This will sort assets by asset_label:
$param->{asset_loop} = $assets;
Change to:
$param->{asset_loop} = [ map $_->[1], sort { $a->[0] cmp $b->[0] } map { [ $_->{asset_label}, $_ ] } @$assets ];
$MT_HOME/tmpl/cms/dialog/asset_insert.tmpl
Update the script that inserts the asset into the list of assets once selected.
Line43
myAssetLink.appendChild(document.createTextNode('<mt:AssetLabel encode_js="1"> [<mt:AssetFileName encode_js="1">]'));
Change to:
myAssetLink.appendChild(document.createTextNode('<mt:AssetFileName encode_js="1">'));
Leave a comment