Help - Search - Members - Calendar
Full Version: How To Change The Sort_by On Pages
Movable Type Community Forum > Additional Resources > Tips and Tricks
Pinha
I don't know if i searched enough but im trying solve a need in MT at least for 3 days... and i havent found how!!! Even tried to creat a plugin!

Well, first i needed to sort Folders and i found a plugin to do it and it works great.
But now i need so sort Pages inside Folders so i tried this:

1. Created a new field on mt_entry database table named "entry_order_number";
2. On the entries with class "page" i set the field to 1, 2, 3, 4 in non alpha order;
3. went to the template "Page Listing" and changed

<mt:Pages sort_by="title" sort_order="ascend">

to

<mt:Pages sort_by="order_number" sort_order="ascend">

4. Re-Published all pages/blog
5. Didn't work!

NEED:

Show Folders and Pages in order_number set in the database table where pages are stored

Exemple:

Folder X
- B Page
- A Page
- Z Page
- L Page

Etc.

CURRENT:

MT 4.1

Plugin SortCatFld installed.
Page Listing Template part that show folders:

CODE
<mt:TopLevelFolders sort_method="SortCatFld::Sort">
<mt:FolderHeader>
<ul class="widget-list">
</mt:FolderHeader>
<li class="widget-list-item"><b><$mt:FolderLabel$></b>
<mt:Pages sort_by="title" sort_order="ascend">

<mt:PagesHeader>
<ul class="widget-list">
</mt:PagesHeader>
<li class="widget-list-item"><a href="<$mt:PagePermalink$>" title="<$mt:PageTitle$>"><$mt:PageTitle$></a></li>
<mt:PagesFooter>
</ul>
</mt:PagesFooter>
</mt:Pages>
<$mt:SubFolderRecurse$>
</li>
<mt:FolderFooter>
</ul>
</mt:FolderFooter>
</mt:TopLevelFolders>


Can you help me out?
Thank you all in advance...
Regards,
Pinha
Su-
QUOTE (Pinha @ Feb 2 2008, 07:06 PM) *
1. Created a new field on mt_entry database table named "entry_order_number";
2. On the entries with class "page" i set the field to 1, 2, 3, 4 in non alpha order;
3. went to the template "Page Listing" and changed
<mt:Pages sort_by="title" sort_order="ascend">
to
<mt:Pages sort_by="order_number" sort_order="ascend">
4. Re-Published all pages/blog
5. Didn't work!

I'm confused. Did you actually expect this to work? Why?
You can't just add a column to the database and expect MT to know what to do with it. Are you leaving out several steps in what you did above, or something? You mentioned writing a plugin at the beginning of your message and then never brought it up again.
Pinha
I didnt leave steps behind and you sould read all the post...
I changed SORT_BY in MTPAGE TAG!
I thought MT would sort by any field on the table passing it as ARG to the SQL QUERY

The plugin was something like this:

CODE

package MT::Sort;

use MT::Entry;
use strict;

sub ByOrderNr ($$) {

my ($a, $b) = @_;

my ($a_entry) = MT::Entry->load( { blog_id => $a->blog_id }, {
'sort' => 'order_number', direction => 'ascend', limit => 1, class => 'page' });

}

1;

__END__


But has im not yet inside MT code (either perl) i just didnt get it to work...

Anyway, thanks for the help (watever that was)...

Pinha
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.