Difference between revisions of "CCAPI Updating Elements"
(Created page with '== Overview== The CCAPI Element object allows you to add/edit content for textblocks and custom elements. It requires that your site have a proper [[CCAPI Conf…') |
|||
Line 1: | Line 1: | ||
== Overview== | == Overview== | ||
− | The [[CCAPI_Element|CCAPI Element]] object allows you to add | + | The [[CCAPI_Element|CCAPI Element]] object allows you to add or edit content for textblocks and custom elements. Your site must have a proper [[CCAPI Config| CCAPI Config]] file established in the site where you would like to use the CCAPI. |
== Example Usage == | == Example Usage == | ||
Line 39: | Line 39: | ||
− | Based on the "name" of the element passed in, the component will find the configuration from the [[CCAPI Config| CCAPI Config]] file and load the proper pageID/elementID combo | + | Based on the "name" of the element passed in, the component will find the configuration from the [[CCAPI Config| CCAPI Config]] file and load the proper pageID/elementID combo, then populate content. |
== Updating 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 | + | 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|CEData]], it will be the "pageID" field for the record you are using. |
== Chaining Updates with Page Creates == | == Chaining Updates with Page Creates == | ||
− | If you would like to chain a page creation with a page content update | + | 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. |
− | + | 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. | |
− | |||
− | + | Note: | |
− | + | * dataPageID = the Custom Element Instance Record | |
− | + | * pageID = the pages ID which contains a Custom Element | |
+ | |||
+ | [[Category:CCAPI]] |
Revision as of 22:46, 20 December 2009
Overview
The CCAPI Element object allows you to add or edit content for textblocks and custom elements. Your site must have a proper CCAPI Config file established in the site where you would like to use the CCAPI.
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.
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.
Note:
- dataPageID = the Custom Element Instance Record
- pageID = the pages ID which contains a Custom Element