Is it possible to create a content_type_nest_content div with the Javascript API?


(J Stephen) #1

I've written a python wrapper class for the Javascript API, which I am using for content imports. A python script parses some xml for page title, metadata and content, then uses python's urllib2 to post to the JS Api. On creation of a page, the JS API returns the new asset id. When the Javascript API creates a page_standard asset, you get a wysiwyg content div for free as a child of the new page, and you can use setAttribute() to set its html attribute to whatever the content of the page should be. Then you can use setMetadata() to set any metadata for the page.


This works nicely, but I've run into trouble trying to create a content_type_nest_content div on a page instead of a wysiwyg content div. I've reached the point where I think I might have to accept that it's not possible, but if anyone has managed to do it, I'd love to hear about it.


(Nic Hubbard) #2

I think it is working from the default that you set in the System Configuration/Global Preferences for the Content Type. So not sure you can change that on the fly.


(Anthony Barnes) #3

You could potentially mix in some SOAP to cover off the gaps for the code you have already written. You could create a 'template' asset with an un-configured nest content div and use the cloneAsset function of the SOAP API asset service.


The JS API also now has the ability to import assets from XML (see the blog post). It requires that the XML file exists on the server, but you could use this in a similar fashion to the cloneAsset function of the SOAP API, ie import a 'template' standard page asset with an un-configured nest content div.



The main challenge I could see here is that you would have to rename the cloned/imported asset and possibly it's webpath too.


(J Stephen) #4

[quote]
You could potentially mix in some SOAP to cover off the gaps for the code you have already written. You could create a 'template' asset with an un-configured nest content div and use the cloneAsset function of the SOAP API asset service.



The main challenge I could see here is that you would have to rename the cloned/imported asset and possibly it's webpath too.

[/quote]



Thanks very much for the suggestion. I tried this and it works very nicely. You were right about renaming the cloned asset and changing its webpath, but that is straightforward with the Javascript API.



I'm using Python, and the biggest challenge was getting Python working with SOAP.