Hi.
I have a business case, where we must create pages based on external events. I then must create a page with some standard paragraph using code and the Dynamicweb API.
I have gotten some way with this code.
internal static bool CreateEventPage() { try { IPageService service = new PageService(); IParagraphService paragraphService = new ParagraphService(); Page newPage = new Page(6, 484); newPage.ItemType = "myItemType"; var pageId = service.SavePage(newPage).ID; // Item types newPage.Item["Title"] = "From My Api -----!"; newPage.Item["Thumpnail_Title"] = "Thumpnail"; newPage.Item["TeaserText"] = "Teaser!"; newPage.Item["Thumpnail_Alt_Text"] = "Alt text"; newPage.Item.Save(); //Works fine to this point! //Paragraph var MyParagraph = new Paragraph(pageId); MyParagraph.ItemType = "R4_1ColumnFull"; paragraphService.SaveParagraph(MyParagraph); return true; } catch(Exception ex) { ErrorLogger.LogError("Failed to create event", ex); return false; } }
But when creating paragraphs, I get into some trouble. I’m trying to create a page that supports the visual builder, but when my paragraph is saved it is saved like this:
(See attachement)
As you can I’m trying to first create a row that is used in Visual builder, but instead of it being part of the “Grid” it is added to the “Not in template” area of the page, which is not shown. Is there any way to add to a row to a grid on a page, and then add a paragraph to that row through code?
Best regards
Daniel