I have developed a method to bridge the gap between creating page-containers and site-containers and the rules that are defined within them.

Inspired by Michaels idea and my need define rules that apply across sections of a tree, I decided that my approach would be to allow a child node to inherit the containers and rules of its ancestors.

The best way that I could see to do this was to modify the core containers.cfm. I hope that either Daemon like this idea or someone can suggest a better solution that does not require a core modification. The added code is clearly commented, and all existing functionality of containers remains intact.

The basis of this mod is to create a container within a template using the following naming convention. #stobj.objectID#_test!!inherit. The key part is using "!!inherit" to allow for the special processing in container.cfm.

What container.cfm does is look for "!!inherit" at the end of the container name. If found it will apply the rules for that instance, i.e. using the objectID of the page being displayed. If no rules are in that container, then it will look through the node's ancestors for containers with the same name until it finds one with rules. These rules will then be applied.

Please see the attached container.cfm for details. Although I have done preliminary testing, further testing will be needed to ensure that this works in all situations.

I know that we should not tamper with core, but I hope that this idea proves useful and finds it way into core for all to use.

Chris.
oCon = createObject("component","#application.packagepath#.rules.container"); qGetContainer = oCon.getContainer(dsn=application.dsn,label=attributes.label); if (NOT qGetContainer.recordCount) { stProps=structNew(); //extended fourq specific properties stProps.objectid = createUUID(); stProps.label = attributes.label; containerID = stProps.objectID; oCon.createData(dsn=application.dsn,stProperties=stProps,parentobjectid=attributes.objectid); } else if(qGetContainer.recordCount GT 1) { //stick the results in a list - useful if more than one result is returned and we wanna grab the first only containerIDList = valueList(qGetContainer.objectID); containerID = listGetAt(containerIDList,listLen(containerIDList)); } else { containerID = qGetContainer.objectID; } stObj = oCon.getData(dsn=application.dsn,objectid=containerid); //this amounts to a check for the container in refObjects - will be phased out for next milestine release(post V2) qRefCon = oCon.refContainerDataExists(objectid=attributes.objectid,containerid=containerid); if (NOT qRefCon.recordCount) oCon.createDataRefContainer(objectid=attributes.objectid,containerid=containerid);
if (arrayLen(stObj.aRules)) { if(attributes.preHTML neq "") writeoutput(attributes.preHTML); oCon.populate(aRules=stObj.aRules); if (attributes.postHTML neq "") writeoutput(attributes.postHTML); }
---
You are currently subscribed to farcry-dev as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to