# Ordering of pages

**URL:** <https://www.ruby-forum.com/t/ordering-of-pages/83469>\
**Category:** Radiant CMS\
**Created:** [January 26, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469 "2007-01-26T13:15:03Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 30, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/21 "2007-01-30T20:18:42Z")

</div>

On 1/30/07, Jacob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ahh, attempting to implement 2 features at once? re-ordering as well as  
> parent/hierarchy changing?  
> (snipped a bunch)

#199 actually has a patch that does re-ordering quite well (some  
assembly required, but I’m using it on a few sites). As it stands,  
the icon/grabber is not pretty. I was thinking it could be tweaked by  
putting the grabber on the end (or beginning) of the row as a textured  
rectangle.

The re-parenting portion of it is no-good though, as it uses rather  
unattractive arrow icons that clutter up the UI a bit. I use the patch  
without re-parenting because I personally think re-parenting is bad  
(breaks URL’s… if you are careful with your site you shouldn’t really  
need to do it… in a perfect world).

-Tom

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 30, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/22 "2007-01-30T23:42:06Z")

</div>

John W. Long wrote:

> Loren J. wrote:
> 
> > I don’t currently feel qualified to work-up a new patch nor improve  
> > the existing one, but I’ve got $$$ (seriously) for the first one to  
> > do it well enough to get it included in a core release.
> 
> I have a client who wants to help foot the bill for this. Contact me  
> directly if you want to help.

Here’s the first pass after a day’s work (works with mental):

[http://dev.radiantcms.org/radiant/attachment/ticket/45/sortable\_pages.mental.diff](http://dev.radiantcms.org/radiant/attachment/ticket/45/sortable_pages.mental.diff)

The patch doesn’t address the reparenting issue. I’m going to have a go  
at that as well, but am working on this this in iterations.

Please have a look if you have a moment.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 3:42am UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/23 "2007-01-31T03:42:20Z")

</div>

> Here’s the first pass after a day’s work (works with mental):
> 
> [http://dev.radiantcms.org/radiant/attachment/ticket/45/sortabl](http://dev.radiantcms.org/radiant/attachment/ticket/45/sortabl)  
> e\_pages.mental.diff
> 
> The patch doesn’t address the reparenting issue. I’m going to  
> have a go  
> at that as well, but am working on this this in iterations.

What happened to the original work of changing the page list to be

's and - I was planning on doing some work to allow pages to break their children  
up into independently expanding sections (ie, by year on the archive  
pages so you don’t get 1200 articles loading up), but was planning on  
switching to a list-based view first.

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 2:28am UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/24 "2007-01-31T02:28:17Z")

</div>

John,

This looks good to me. I may have preferred to not going to a  
separate screen but don’t really have any objection to it either –  
this works for me.

I’m very happy to see the default sort order priority beginning with  
position.

Thanks for putting this out there, it’s great to see this coming  
together, or at least beginning 🙂

Great!

Loren

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 5:37am UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/25 "2007-01-31T05:37:29Z")

</div>

Daniel S. wrote:

> What happened to the original work of changing the page list to be
> 
> 's and - 's and just directly allowing sorting there? I remember things moving enthusiastically in that direction but then falling off the radar. Were there issues with making it render properly cross-browser?

I know there is a lot of built in support for sorting lists in Rails,  
but I’m still hoping a solution can be pulled together that’s not too  
complicated and uses a tables.

I’ve looked at some of the other sorting patches, but they seem to be  
incompatible with mental.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 6:59am UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/26 "2007-01-31T06:59:33Z")

</div>

> I know there is a lot of built in support for sorting lists in Rails,  
> but I’m still hoping a solution can be pulled together that’s not too  
> complicated and uses a tables.
> 
> I’ve looked at some of the other sorting patches, but they seem to be  
> incompatible with mental.

Well, the changing of the code from tables to lists made for much  
cleaner html, ruby and javascript code (at the expense of more  
complicated css). I think it would be a good idea to go ahead with that  
regardless of sorting - predicated of course on having css that works  
cross-browser.

I created a sorting patch in my ‘on crack’ branch - I might dig that  
back up in the near future and see how that goes.

Also the discussion on reparenting - I don’t think reparenting should be  
a drag/drop operation - I quite liked to idea of having a ‘parent’  
drop-down list in the page metadata (though that also has the problem  
with large numbers of pages). I’d also like to see the option of leaving  
behind a redirect action to maintain cool uris.

Dan.

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 6:13pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/27 "2007-01-31T18:13:00Z")

</div>

I assume user input is welcome here…

I have a “small” business site that will easily have 100-200 pages that  
I’m planning to move to radiant. On its way to publication, it is  
common to adjust the parent of a page as we settle on our structure and  
linking.

> I don’t think reparenting should be a drag/drop operation - I quite liked to  
> idea of having a ‘parent’ drop-down list in the page metadata (though that  
> also has the problem with large numbers of pages).

A drop-down list would be hard on the writers having to read through all  
possible parents. By the way, I am more likely to move a page up or  
down a level than to move it laterally (make its aunt/uncle its new  
parent). A lot has to do with the interface design, but teaching users  
one operation (drag-drop) for everything should be easier than  
remembering two and when each is to be used.

Another thought. I’ve only looked briefly at things like scriptaculous  
JS drag-drop operations. Do they allow for cases where the destination  
location is off-screen (scrolling needed)? Otherwise you still run into  
problems with large numbers of pages (though you could move a page using  
multiple hops).

> I’d also like to see the option of leaving behind a redirect action to  
> maintain cool uris.

BIG thumbs up for this idea. I wish all the uri adjusting only happened  
on the way to publishing but the real world doesn’t seem to always work  
that way for me.

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/28 "2007-01-31T20:22:43Z")

</div>

> > I’d also like to see the option of leaving  
> > behind a redirect action to maintain cool uris.

I think it should be easy enough to write a tag for doing redirects…  
(You don’t need a special kind of “redirect” page, you can just create a  
new page and insert this tag). Or perhaps this tag should actually be  
provided by a custom page type…

Here’s some snippets of code from my own hacked-up version of Radiant:

—in standard\_page.rb—

# 

# \<r:redirect to\_url="" /\>

# 

define\_tag ‘redirect’ do |tag|  
to\_url = tag.attr[‘to\_url’]  
raise RedirectException.redirect\_to(to\_url);  
end

------redirect\_exception.rb—

class RedirectException \< Exception

attr\_accessor :redirect\_to\_url

def self.redirect\_to(redirect\_to\_url)  
new\_exception = RedirectException.new(“redirect”);  
new\_exception.redirect\_to\_url = redirect\_to\_url;  
return new\_exception;  
end

end

----in site\_controller.rb----

def show\_page  
url = params[:url].to\_s  
@page = find\_page(url)  
if @page.nil?  
render :template =\> ‘site/not\_found’, :status =\> 404  
else  
begin  
@page.process(request, response)  
rescue RedirectException =\> e  
redirect\_to e.redirect\_to\_url;  
end  
@performed\_render = true  
end  
rescue Page::MissingRootPageError  
redirect\_to(:controller =\> ‘admin/welcome’)  
end

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 6:53pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/29 "2007-01-31T18:53:49Z")

</div>

Daniel S. wrote:

> Also the discussion on reparenting - I don’t think reparenting should be  
> a drag/drop operation - I quite liked to idea of having a ‘parent’  
> drop-down list in the page metadata (though that also has the problem  
> with large numbers of pages).

I think I favor drag and drop reparenting, but with the option to  
“Cancel” if you make a mistake. Much like the implementation of the  
current reordering patch.

> I’d also like to see the option of leaving  
> behind a redirect action to maintain cool uris.

Not sure about this myself. I have a feeling a lot of users would find  
this very annoying.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/30 "2007-01-31T20:25:55Z")

</div>

Here’s another suggestion for how you could potentially select a new  
parent for a particular page.

From the edit screen you see a basic text box with the URL of the parent  
page.

If you start typing into this box, it becomes an AJAX-y auto-complete  
box with the names of pages whose page name or url matches what you are  
typing…

when you select a parent, the full url is shown in the text box.

When you actually save the page you were editing, the controller has to  
figure out the actual page object that corresponds to the url and assign  
it as the parent, with validation etc…

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/31 "2007-01-31T23:37:23Z")

</div>

Do we all think that re-ordering and re-parenting should be part of the  
core of radiant, or an extension?

How, in general, do we ever decide this sort of thing?

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 11:33pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/32 "2007-01-31T23:33:01Z")

</div>

> If you start typing into this box, it becomes an AJAX-y auto-complete  
> box with the names of pages whose page name or url matches what you are  
> typing…
> 
> when you select a parent, the full url is shown in the text box.

The issue with separating parenting from ordering is twofold:  
1.) Two different actions for the user to learn.  
2.) If you want the 2nd document under parent #1 to become the 3rd  
document under parent #2, you have to do two steps. Parent, then order.

Fundamentally, it just goes against the user’s goal. In the their mind,  
the thought is simply “I want this moved to here” and a single operation  
follows that thinking.

The complexity of implementation – well that’s a whole other issue.

BTW, John W. Long wrote:

> I think I favor drag and drop reparenting, but with the option to  
> “Cancel” if you make a mistake. Much like the implementation of the  
> current reordering patch.

The cancellation step is where I would provide the _option_ of  
automatically creating a redirect page upon completion (say, a box –  
unchecked by default – to preserve the old uri).

If you want to get really fancy, you could control the default checkbox  
state or even if the user has that option in some admin configuration.  
This way an admin could establish it as a site policy.

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/33 "2007-01-31T23:45:16Z")

</div>

> I think it should be easy enough to write a tag for doing  
> redirects…  
> (You don’t need a special kind of “redirect” page, you can  
> just create a  
> new page and insert this tag). Or perhaps this tag should  
> actually be  
> provided by a custom page type…

Since the changes that we’re talking about are on mental, it’s actually  
MUCH simpler to just introduce a redirect page than to bastardize the  
tags.

class RedirectPage \< Page  
def headers  
location = part(‘content’).content  
{  
‘Status’ =\> 302,  
‘Location’ =\> location  
}  
end  
def render  
‘’  
end  
end

You’d probably also want a page status that takes the page out of the  
‘\<r:children\>’ set, yet still makes the page available for rendering  
(the hidden status doesn’t cover that does it?)

Dan.

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [February 1, 2007, 12:09am UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/34 "2007-02-01T00:09:18Z")

</div>

Daniel S. wrote:

> MUCH simpler to just introduce a redirect page than to bastardize the  
> def render  
> ‘’  
> end  
> end
> 
> You’d probably also want a page status that takes the page out of the  
> ‘\<r:children\>’ set, yet still makes the page available for rendering  
> (the hidden status doesn’t cover that does it?)

You could make the page “virtual”.

def virtual?  
true  
end

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [January 31, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/35 "2007-01-31T23:43:15Z")

</div>

Jacob B. wrote:

> Do we all think that re-ordering and re-parenting should be part of the  
> core of radiant, or an extension?
> 
> How, in general, do we ever decide this sort of thing?

Generally, I just make a decision and people live with it. 🙂

Specifically, I try and listen to other opinions and implement the ideas  
I like best.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Anton\_J\_Aylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Anton\_J\_Aylward](https://www.ruby-forum.com/u/Anton_J_Aylward)\
**Post date:** [February 1, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/ordering-of-pages/83469/36 "2007-02-01T15:31:27Z")

</div>

On 1/30/07, John W. Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://dev.radiantcms.org/radiant/attachment/ticket/45/sortable\_pages.mental.diff](http://dev.radiantcms.org/radiant/attachment/ticket/45/sortable_pages.mental.diff)
> 
> The patch doesn’t address the reparenting issue. I’m going to have a go  
> at that as well, but am working on this this in iterations.
> 
> Please have a look if you have a moment.

It works well, though IMO it is more intuitive to allow DnD  
re-ordering in the main Pages view.

-T

[Previous page](https://www.ruby-forum.com/t/ordering-of-pages/83469.md?page=1)
