Hello,
maybe someone could share a code which creates a Page programmatically and assigns a template to it?
Thank you
Augustas
[SOLVED] How to create a page using API?
[SOLVED] How to create a page using API?
Last edited by Augustas on Sat Apr 11, 2015 8:59 am, edited 2 times in total.
Re: How to create a page using API?
I saw this topic. http://forum.cmsmadesimple.org/viewtopi ... =6&t=71835
Maybe it helps a bit.
Maybe it helps a bit.
Re: How to create a page using API?
Thank you Jos for the effort, I saw this topic, but it has no information I need.Jos wrote:I saw this topic. http://forum.cmsmadesimple.org/viewtopi ... =6&t=71835
Maybe it helps a bit.
calguy1000 just mentions that
"There is lots of documentation in the API docs"
and
"Creating content pages is a bit more complicated, but not by much."
and then he gives some hints for CMSMS 2.0 users, while I am working with 1.11.X
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: How to create a page using API?
This is 2.0 code. The 1.x code is similar (there is no concept of a design).
$contentobj = new Content;
$contentobj->SetName('Test Page');
$contentobj->SetAlias();
$contentobj->SetMenuText('Test Page');
$contentobj->SetPropertyValue('searchable',1);
$contentobj->SetPropertyValue('design_id',$design_id);
$contentobj->SetTemplateId($template_id);
$contentobj->SetOwner(1);
$contentobj->SetParentId(-1);
$contentobj->SetActive(TRUE);
$contentobj->SetShowInMenu(TRUE);
$contentobj->SetCachable(TRUE);
$contentobj->SetPropertyValue('content_en',$some_html);
$contentobj->Save();
You will need to update the hierarchy positions after creating a new page programattically. but that is a simple method in the contentoperations class
$contentobj = new Content;
$contentobj->SetName('Test Page');
$contentobj->SetAlias();
$contentobj->SetMenuText('Test Page');
$contentobj->SetPropertyValue('searchable',1);
$contentobj->SetPropertyValue('design_id',$design_id);
$contentobj->SetTemplateId($template_id);
$contentobj->SetOwner(1);
$contentobj->SetParentId(-1);
$contentobj->SetActive(TRUE);
$contentobj->SetShowInMenu(TRUE);
$contentobj->SetCachable(TRUE);
$contentobj->SetPropertyValue('content_en',$some_html);
$contentobj->Save();
You will need to update the hierarchy positions after creating a new page programattically. but that is a simple method in the contentoperations class
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: How to create a page using API?
That's useful, thank you.