In core / packages / types is dmNavigation.cfc, I would like to extend the method getChildren which only accepts dsn, objectid, and status as arguments, I would like to include a new argument so the query return suits my needs. We have many sites and I don’t want to modify core, I would like to override dmNavigation getChildren in core in my specific project. I think all I need to do is drop dmNavigation.cfc in my project somewhere, but I’m not sure where, can anyone advise?
Just drop a cfc called dmNavigation.cfc that extends the core dmNavigation into /projects/yoursite/packages/system and update app
Thanks @seancoyne, I ended up dropping the file into project / packages / types and it worked.
For those who are curious, I extended / modified getChildren to accept a new argument called “group” which plays off the lNavIDAlias for navigation nodes. This allows us to effectively group our navigation nodes for where they need to be, IE “header” or “footer” or “subnav” at the query level instead of the client level through “ifs” and “loops”. Now a user can type into the “alias” field for the navigation folder where those items should live physically on the page.
dmNavigation.cfc
<cffunction name="getChildren" access="public" returntype="query" output="false" hint="Returns the navigation children (dmHTML page for example)">
<cfargument name="objectid" required="yes" type="UUID" hint="Object ID of children's parent to be returned">
<cfargument name="dsn" required="yes" type="string" default="#application.dsn#">
<cfargument name="status" required="no" type="string" default="approved">
<cfargument name="group" required="no" type="string" default="header">
<cfset var o = createObject("component", "#application.packagepath#.farcry.tree")>
<cfset var navFilter=arrayNew(1)>
<cfset var qNav = '' />
<cfset navfilter[1]="status = '#arguments.status#'">
<cfset navfilter[2]="grouping = '#arguments.group#'">
<cfset qNav = o.getDescendants(objectid=arguments.objectid, lColumns='title,lNavIDAlias,status,grouping', depth=1, afilter=navfilter)>
<cfreturn qNav>
</cffunction>
It will work in types, but since it is a system content type, it’s proper place is in system. Do what you like though.
There was no system folder, so I guess I would have had to create one. Is this a semantic thing? You mention it’s proper place… I’m all about, “the right way”. Could you elaborate on “system” folder. I have never seen or heard of it. Thanks!
Yeah, there are lots of folders that don’t get created for you. You just needed to add one. packages/system is where you override core content types. (dmNavigation, dmHTML, dmFile, etc, etc). packages/types is for YOUR types, packages/rules is for YOUR rules. packages/forms is for your configurations and other forms, packages/lib is where you can place cfc libraries and packages/formtools is for your (or core override) formtools.
Awesome! Thanks for the explanation.