[ContentBox 2.1.0.00122] Drag and Drop Page Order Not Saving

In basing custom content types on existing content types, I ran into an issue where my drag-and-drop re-ordering wasn’t working. When I checked the drag-and-drop page re-ordering I was basing it on, I discovered that changes in page orders in the contentbox-admin module weren’t being saved, either.

Digging into the issue, I found that two things were happening that were preventing the re-ordering from happening:

  1. The passed data was not being URLDecoded
  2. The passed data had an incorrect replace method

The code as it stands is:

contentbox-admin:handlers.pages

function changeOrder( event, rc, prc ){
event.paramValue(“tableID”,“pages”);
event.paramValue(“newRulesOrder”,“”);
rc.newRulesOrder = ReplaceNoCase(rc.newRulesOrder, “&#rc.tableID#=”, “,”, “all”);
rc.newRulesOrder = ReplaceNoCase(rc.newRulesOrder, “#rc.tableID#=,”, “”, “all”);

The adjusted code to enable it to work:

function changeOrder( event, rc, prc ){
event.paramValue(“tableID”,“pages”);
event.paramValue(“newRulesOrder”,“”);

rc.newRulesOrder = urlDecode(rc.newRulesOrder);
rc.newRulesOrder = ReplaceNoCase(rc.newRulesOrder, “&#rc.tableID#=”, “,”, “all”);
rc.newRulesOrder = ReplaceNoCase(rc.newRulesOrder, “#rc.tableID#=”, “”, “all”);

The changes are adding the urlDecode() line and removing the comma after the equal sign in the last line (which caused the replace to not happen since there is no comma there).

So those would be proposed changes to ContentBox. In the interim, you can make use of the methodology in http://www.andyscott.id.au/blog/a-funky-way-to-replacing-captcha-in-contentbox to override the handler to enact this change without modifying the core contentbox application. While the link talks about overriding a plugin, it can work with any cfc loaded by wirebox. You just need to call your overriding cfc appropriately.

Create your object’s cfc file as a cfc that extends the handler you want to override. Then use a switch to target the individual cfc and set the interceptData.target to the appropriate type of object. In this case, you need to get the bean of the handler, which means using the handlerservice.

public void function afterInstanceCreation() {
var handlerService = “”;

// Get object’s name and clean it up so it doesn’t include anything but the module and subsequent namespaces

var objectName = GetMetaData(interceptData.target).name;

objectName = REReplace(objectName,“^(” & [[application.root.NameSpace]] & “)?modules.”,“”);

switch(objectName){
case “contentbox-admin.handlers.pages”:
handlerService = controller.gethandlerService();
interceptData.target = handlerService.gethandler(handlerService.getRegisteredHandler(“[[your override module]]:[[your override handler]].init”),controller.getRequestService().getContext());
break;
default:
return;
}
}

Note that application.root.NameSpace is a value I added to my application scope, along with a few others, to help with navigating the issues that are created when installing your contentbox site somewhere beneath the root of your web server. The structure itself does nothing, of course, but it gives you quick access to variables that you can make use of throughout your application. To do this, I added the following code at the beginning of my site’s application.cfc > onApplicationStart() function:

var serverRoot = ExpandPath(‘/’);
var appRoot = COLDBOX_APP_ROOT_PATH;
var extraFolders = Replace(appRoot,serverRoot,“”);
var extraNameSpaces = Replace(extraFolders,“",”.",“ALL”);

application.root = StructNew();
application.root.Folder = extraFolders;
application.root.WebFolder = Replace(extraFolders,“",”/",“ALL”);
application.root.NameSpace = extraNameSpaces;

So that gives you everything you need to know to:

  • Fix the drag-and-drop re-ordering of pages

  • Override any wireboxed object (thanks to Andrew Scott)

  • Create an application scope structure to help with non-root-level contentbox sites.

Luis, let me know if you want me to create a jira ticket (and in which project: CONTENTBOX or CTBOXUTILITIES) to address the drag-and-drop re-ordering bug.

John

I have added two new interception points for versions, so you can override for custom con tent types:

[CONTENTBOX-557](https://ortussolutions.atlassian.net/browse/CONTENTBOX-557)
Versions now get two new interception points: cbadmin_onVersionIndex, cbadmin_onVersionDiff

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Great. That change doesn’t pertain to this topic, however. :slight_smile:

For those at home, this change pertains to event.setView ignores module.

As for this post on drag-and-drop re-ordering, Luis, I do hope you found it useful.

Thanks,
John

Ohh yes that too is fixed