A few days ago Andrew Mercer asked about use of categories in dmHTML.
I have just implemented a rule that combines the categories entered in
the dmHTML and any extra categories entered with the rule to pull
dynamic content into a container.
What this gives me is a container/rule that can be set to used across
the entire website or for particular dmHTML display methods, but the
categories to determine which dynamic content is used are maintained by
the site admin users by applying categories to the dmHTML objects. Much
more flexible than having to set a rule for each dmHTML object.
I have used this on a project to set up keyword categories, then setting
the keywords against the dmHTML and dmNews, all news items that match
the categories for each page will be pulled into and viewed on the page
by one site-wide rule.
Adding the following code to the execute method for my rule will get the
category id's for the page. I can then either append these categories to
the rule categories or use independently.
<cfinvoke component="#application.packagepath#.farcry.category"
method="getCategories" returnvariable="lCategegoryIDs">
<cfinvokeargument name="objectID" value="#request.stobj.objectID#"/>
<cfinvokeargument name="bReturnCategoryIDs" value="true"/>
</cfinvoke>
This has given me a very flexible and powerful extension to the existing
container/rules content selection.
In testing this I found a bug in Farcry. When sending a dmHTML object
back to draft and then approving it again the categories were not being
maintained and transferred from live to draft and back again. The
categories were OK at the time of dmHTML creation and the initial
approval stage, but any subsequent modifications were never applied.
I had to modify farcry_core/tags/navajo/createDraftObject.cfm and
farcry_core/packages/farcry/_versioning/sendObjectLive.cfm to copy and
update the categories from live to draft and back again. See attached -
all mods marked with my name.
Simple fix and it works.
hth,
Chris.
stProps=structCopy(stObject);
stProps.objectid = createUUID();
stProps.lastupdatedby = session.dmSec.authentication.userlogin;
stProps.datetimelastupdated = Now();
stProps.createdby = session.dmSec.authentication.userlogin;
stProps.datetimecreated = Now();
// dmHTML specific props
//stProps.displayMethod = "display";
stProps.status = "draft";
//dmNews specific props
stProps.publishDate = now();
stProps.expiryDate = now();
stProps.versionID = URL.objectID;
// create the new OBJECT
oType = createobject("component", application.types[stProps.TypeName].typePath);
stNewObj = oType.createData(stProperties=stProps);
NewObjId = stNewObj.objectid;
oAuthentication = request.dmSec.oAuthentication;
stuser = oAuthentication.getUserAuthenticationData();
application.factory.oaudit.logActivity(objectid="#URL.objectid#",auditType="Create", username=StUser.userlogin, location=cgi.remote_host, note="Draft object created");
//this will copy containers and there rules from live object to draft
oCon = createobject("component","#application.packagepath#.rules.container");
oCon.copyContainers(stObject.objectid,stProps.objectid);
SELECT categoryID
FROM #application.dbowner#refCategories
WHERE objectID = '#url.objectId#'
INSERT INTO #application.dbowner#refCategories (categoryID,objectID)
VALUES ('#qGetCategories.categoryID#', '#stProps.objectid#')
stResult = structNew();
stResult.result = false;
stResult.message = 'No update has taken place';
if (NOT isDefined("typename"))
{
q4 = createObject("component","farcry.fourq.fourq");
typename = q4.findType(objectid=objectid);
}
o = createObject("component",application.types[typename].typePath);
stLiveObject = o.getData(arguments.stDraftObject.versionID);
//set up the dmArchive structure to save
stProps = structNew();
stProps.objectID = createUUID();
stProps.archiveID = stLiveObject.objectID;
stProps.objectWDDX = stLiveWDDX;
stProps.lastupdatedby = session.dmSec.authentication.userlogin;
stProps.datetimelastupdated = createODBCDateTime(Now());
stProps.createdby = session.dmSec.authentication.userlogin;
stProps.datetimecreated = createODBCDateTime(Now());
stProps.label = stLiveObject.title;
//end dmArchive struct
UPDATE #application.dbowner#refCategories
SET objectID = '#stProps.objectID#'
WHERE objectID = '#stLiveObject.objectId#'
//copy all container data to live object
oCon = createobject("component","#application.packagepath#.rules.container");
//copy draft containers to live
oCon.copyContainers(srcObjectID=arguments.stDraftObject.objectId,destObjectID=stLiveObject.objectID,bDeleteSrcData=1);
//Archive the object
oArchive = createobject("component","#application.packagepath#.types.dmArchive");
oArchive.createData(stProperties=stProps);
//delete the old draft
o.deleteData(objectid=arguments.stDraftObject.objectid);
//Start Chris Kent - save old fraft id
olddraftid = arguments.stDraftObject.objectid;
//End Chris Kent - save old fraft id
//need to set stDraft object to live for fourq update. Update datetimeLastUpdated and clear out versionID
arguments.stDraftObject.objectid = stLiveObject.objectID;
arguments.stDraftObject.versionID = "";
arguments.stDraftObject.dateTimeLastUpdated = createODBCDateTime(Now());
arguments.stDraftObject.dateTimeCreated = createODBCDateTime(arguments.stDraftObject.dateTimeCreated);
o.setData(stProperties=arguments.stDraftObject,auditNote='Draft version sent live');
stResult.result = true;
stResult.message = 'Update Successful';
UPDATE #application.dbowner#refCategories
SET objectID = '#stLiveObject.objectId#'
WHERE objectID = '#olddraftid#'
---
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