RadarBug
RadarBug

Reputation: 807

Is it possible to add content programatically to Orchard Core CMS?

I'm looking at Orchard Core as a CMS for a new project and so far it seems like a good fit. I do however need to transfer a significant amount of content and was unable to identify a way of migrating the content I have extracted from the old CMS into Orchard Core.

Upvotes: 1

Views: 733

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

The easiest way to transfer contents from another CMS is to go through Orchard's recipe format as an intermediary. See the Agency recipe for an example of a recipe. There's a lot in there, content type creation, settings, etc., but you don't have to include all that. The part that should interest you is near the end, where content items get created. Each content item creation looks something like this:

{
  "ContentItemId": "[js:uuid()]",
  "ContentItemVersionId": "[js:uuid()]",
  "ContentType": "Milestone",
  "DisplayText": "Our Humble Beginnings",
  "Latest": false,
  "Published": false,
  "Owner": null,
  "Author": "[js: parameters('AdminUsername')]",
  "Milestone": {
    "Date": {
      "Text": "2009-2011"
    },
    "Image": {
      "Paths": [
        "/about/1.jpg"
      ]
    }
  },
  "HtmlBodyPart": {
    "Html": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ut voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae sit vero unde, sed, incidunt et ea quo dolore laudantium consectetur!"
  },
  "TitlePart": {
    "Title": "Our Humble Beginnings"
  }
}

This one is a setup recipe, but recipes can be executed at any time, not just setup.

Upvotes: 3

Related Questions