Merv

Widget Sets

Vote 0 Votes

I have an installation with several blogs and a good number of custom Global Widgets.
When creating or editing a widget set on a Blog, the Available Widget column appears in somewhat random order. I want to sort the Available Widgets by name. In browsing the MT files I found the edit_widget.tmpl and the following code which displays the Available Widgets column:


<div id="available-column" class="pkg">
<p><__trans phrase="Available Widgets"></p>
<mt:loop name="available">
<div id="module-<mt:var name="id" escape="html">" class="module pkg">
<div class="module-name"><a href="javascript:void(0)"><mt:var name="name" escape="html"></a></div>
<div class="module-edit"><a href="<mt:var name="script_url">?__mode=view&amp;_type=template&amp;id=<mt:var name="id" escape="url">&amp;blog_id=<mt:var name="blog_id" escape="url">" target="_new"><__trans phrase="edit"></a></div>
</div>
</mt:loop>
</div>

I also found this code in Template.pm (around line 2400):

$param->{installed} = \@inst_modules if @inst_modules;
my @avail_modules = map { {
id => $_, name => $all_widgets{$_}{name}, blog_id => $all_widgets{$_}{blog_id}
} } keys %all_widgets;
$param->{available} = \@avail_modules;

my $res = $app->run_callbacks('cms_edit.widgetset', $app, $id, $wtmpl, $param);
if (!$res) {
return $app->error($app->callback_errstr());
}

$app->load_tmpl('edit_widget.tmpl', $param);

Based on the documentation for mt:Loop I thought I could add sort_by="value" to the loop for the "available" hash but it does not effect the order of the display. I even tried sort_by="name" since name is one of the hash keys.

Where am I going wrong? I don't care about the case where one might drag a Widget from installed back into available. I just want the initial display sorted by Widget Name, ASC.

Is there a simple hack to the code setting up the "available" hash in Template.PM?

Your advice is appreciated.
Merv

Reported on Movable Type 4.3

2 Replies

| Add a Reply

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1774 6167

Last Topic: Template modules by Zielun on Feb 16, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1434 5088

Last Topic: Maintenance announcement by Nick on Feb 17, 2012

695 2912

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

174 740

Last Topic: Captcha images rendering slowly by ScottM on Feb 12, 2012

190 568

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012