In the docs for contentLib.create, the parameter list mentions the parameter “branch”. In the example below, this parameter is not used. Instead, the example lists “draft: true” as a possible parameter. Which is correct? Do they do the same thing?
Also, when I output the result after creating the content, there is no information about which branch the content was created in. This differs from the example in the docs, which specifies that the result should have a “draft”-element. Is this intended?
You are right.
The example and result are not up-to-date. It should be written "branch: ‘draft’” instead of "draft: true”
About the result of the content creation: Yes there is no information about its branch inside of the content. It is intended
I will fix the documentation. Thank you for letting us know
When I create a content in branch: “master”, or omit the parameter and create the content in the “portal/master”-context, the content does not appear in the content list in the admin console.
If I create the content in branch: “draft”, or create the content in the “portal/draft”-context, it appears as expected.
It seems to me that a content needs to be in the draft branch to be listed in the admin console. Is this a bug in 6.0.X, or intended behaviour?
It is intentional, yes. What you see when working in admin is the draft branch. Thus, anything created in master branch (without going through draft branch first) will not be visible.
We are working on an “pull/update” feature that lets you update draft with changes from master (like a reverse publish).
I have leveraged this MASTER content functionality when using data that has been imported from external resources.
This way you separate content that can be edited and not.
The downside is that content in draft mode depending on content in MASTER can’t be previewed correctly.
Runar, if you do this consequently, you could change your api calls for the specific “master only items” to search for content in master branch spesifically.
Thanks, Thomas! I even found this exact thing mentioned in the docs. Silly me for not reading the documentation thoroughly enough.
Is there an easy way for me to create the content in the draft branch, and publish it programatically with JavaScript? Or is this the pull/update feature you mention?
Thanks a bunch for the tip, Runar! I did not know about those rest endpoints. Was pretty easy to do what you describe, and I now have similar functionality available in my project.