CCAPI Updating Elements

From ADF Docs
(Redirected from CCAPI Element)
Jump to: navigation, search

Overview

Two of the key calls available in the CommonSpot CCAPI are "populateTextblock" and "populateCustomElement". The CCAPI Libary Component has a CFC called "csContent" which will make easy to call either of these two calls.

Example Usage

<cfscript>
 // custom element sample
 tmp = structNew();
 tmp.field1 = "test";
 tmp.field2 = "test 2";
 // get the content object from the factory
 csContentObj = server.ADF.getBean("CSContent_1_0");
 // call populate content (sorry I wish it was more difficult then that)
 results = csContentObj.populateContent("elementName", tmp);  
</cfscipt>
<cfscript>
 // textblock sample
 tmp = structNew();
 tmp.textblock = "test";
 tmp.caption = "test 2";
 // get the content object from the factory
 csContentObj = server.ADF.getBean("CSContent_1_0");
 // call populate content (sorry I wish it was more difficult then that)
 results = csContentObj.populateContent("elementName", tmp);  
</cfscipt>
<cfscript>
 // custom element sample with update
 tmp = structNew();
 tmp.field1 = "test";
 tmp.field2 = "test 2";
 tmp.dataPageID = 29333;
 // get the content object from the factory
 csContentObj = server.ADF.getBean("CSContent_1_0");
 // call populate content (sorry I wish it was more difficult then that)
 results = csContentObj.populateContent("elementName", tmp);  
</cfscipt>


Based on the "name" of the element passed in, the component will find the configuration from the CCAPI Config file and load the proper pageID/elementID combo, then populate content.

Updating Content

By default, if you are working with a textblock, content will always be updated. If you would like to update a Custom Element record, be sure to add "dataPageID" into your data struct (see example above). You will receive the "dataPageID" in your renderhandler. If you use CEData, it will be the "pageID" field for the record you are using.

Chaining Updates with Page Creates

If you would like to chain a page creation with a page content update, add the "pageID"/"subsiteID" combo to your data before passing to the populateCustomElement method.

  • dataPageID = the Custom Element Instance Record
  • pageID = the pages ID which contains a Custom Element

Note: You would be more likely to chain a populateCustom Element with a createPage if the page you were creating contained a Local Custom Element.