Thanks for the tip on drag_order, it sounded great.  It took me quite
a bit of trial and error to get it working.  It makes me realize that
the combination of radiant versions, rails versions, and extension
versions can really be a pain in the ass.

Just an opinion, it would seem that moving/reordering pages is a
pretty core function of a CMS.  It would be sensible to me to roll
this drag_order extension into the 0.9 core gem.

Anyway, here is the story of my struggle through getting drag_order
working: -----------------

- Downloaded the latest TAR from GitHub, extracted
- Ran rake radiant:extensions:drag_order:migrate -- failed.
- Ran rake radiant:extensions:drag_order:update -- failed.
- Ran rake radiant:extensions:drag_order:update -t -- failed, but see
that the problem is the "require 'application'" on line two of
drag_order_extension.rb.  Change it to "application_controller"
- Ran rake radiant:extensions:drag_order:update -t -- passed
- Ran rake radiant:extensions:drag_order:migrate -t -- failed, error
from DB that "Pages" table already has a position field (from the
REORDER extension). Edit the migration to comment out the column
creation lines, re-run, passed.
- Restart the server
- Here's what I see on the admin index page:

Working with extensions always makes me feel like a freaking noobie, ugh!

I looked in vendor/extensions/drag_order/app/views/admin/page/ and
everything is there.  Though I wondered why "page" and not "pages" --
renamed the folder to "pages", restarted, and those error messages are
gone.  Here's what I see:

Sweet! Try it and --- uhhh --- nothing happens.  Look at the HTML
source and find this:

<td class='drag_order'><img alt="Drag this icon to move the page"
src="/images/admin/drag_order.png?1259505171" /></td>

Looks reasonable, but there must be some Javascript missing.  Look at
the header area and see prototype, string, effects, tabcontrol,
ruledtable, admin, sitemap, and lowpro javascripts.  Nothing about
drag_order, hmmm.  Look in the file system and I see drag_order.js
under public/javascripts/admin/, so the file is in the right place
just not being included in the header.

I really don't understand how plugins get loaded and such, but I see
the include statements in /app/views/admin/pages/_header.html.haml.
Clearly this file isn't getting picked up for some reason.  As a first
hack, I copy the two include lines to the _header.html.haml of the
REORDER extension, since that one seems to be getting loaded.  Copy
the includes, restart, reload, and it looks good!  I can drag the
handle around and see the purple indicator.

Drop a file, then boom: Application error from the URL
Ugh.  Check out the log and this is what I see:

Processing ApplicationController#move_to (for at
2009-11-29 15:12:57) [GET]
  Parameters: {"rel"=>"106", "action"=>"move_to", "id"=>"75",
"controller"=>"admin/page", "pos"=>"1"}
NameError (uninitialized constant Admin::PageController):

I already know there's something about Page versus Pages, so this
isn't shocking.  First I look in drag_order_extension.rb and find the
"activate" and "deactivate" methods that must be responsible for
telling Radiant about the extension's views, modules, and such.  I
should come back here to figure out why the _header wasn't being
picked up.  Moving on...

I search in drag_order/lib/drag_order for any files containing the
text "PageController" (from the error message).  The only appears in
"page_controller_extensions.rb", so I rename the file itself to
"pages_controller_extensions.rb" and, inside the file, rename the
module to DragOrder::PagesControllerExtensions.

Reload and boom: uninitialized constant
DragOrder::PageControllerExtensions error from the Radiant extension
loader.  Sounds reasonable.  Looking at the initializer code radiant
is calling that activate method that I saw in the
drag_order_extension.rb file, so I'll go look at that.

The lines that caught my eye before looked like
"(Admin::PageController rescue Admin::PagesController)" which seemed
unnecessary if my instance is using pages.  So I do some simplifying
and renaming to end up with this:

def activate :sitemap_head, "drag_order_header" :node, "drag_order" :top, "header"
  Page.send :include, DragOrder::PageExtensions
  Admin::PagesController.send :helper, DragOrder::PageHelper
  Admin::PagesController.send :include, DragOrder::PagesControllerExtensions
  StandardTags.send :include, DragOrder::TagExtensions

I compare that to the activate method of the working REORDER extension
and see that the top three lines are basically identical.  I wonder
why the partials aren't getting picked up.  Maybe this whole method
isn't getting executed??  Restart the server and see what happens...

It loads.  Try to do a drag & drop, and:

Processing ApplicationController#move_to (for at
2009-11-29 15:38:14) [GET]
  Parameters: {"rel"=>"106", "action"=>"move_to", "id"=>"75",
"controller"=>"admin/page", "pos"=>"1"}
NameError (uninitialized constant Admin::PageController):

Maybe it's a routing problem?  I reopen drag_order_extension.rb and
look at the "define_routes" method.  I change this line:

map.with_options :controller => "admin/page" do |page|

to this:

map.with_options :controller => "admin/pages" do |page|

Restart the server, drag and drop...HOLY CRAP IT WORKED!

I at once love and hate the extension system.

- Jeff

On Sun, Nov 29, 2009 at 12:04 AM, Nate <> wrote:
> Arthur Gunn wrote:
>> Hey Jeff,
>> No insights into copy_move functionality, you could of course checkout
>> a previous version, but I wonder why not use:
>> Ajax copy, move and reorder all in one.
> Awesome find. I thought Sean's reorder extension had withered and died.
> Nice to see that it was revived and updated.
> ~Nate
> _______________________________________________
> Radiant mailing list
> Post:
> Search:
> Site:
Radiant mailing list

Reply via email to