Template on Page Create
How do I get the ids for the stock templates?
PageManager pManager = new PageManager(); Guid templateGuid = pManager.GetTemplates().First().Id; App.WorkWith() .Page() .CreateNewStandardPage(PageLocation.Frontend) .Do(p => p.Name = "Page1"; p.Title = "This is a test page"; p.Description = "Some Description here"; p.DateCreated = DateTime.Now; //filled in automatically, but you can control it programatically as well p.UrlName = "page1"; //filled in automatically, but you can set any url name here. p.ShowInNavigation = true; ) .SetTemplateTo(templateGuid) .SaveChanges(); SiteMapBase.Cache.Flush();Hi jaime,
You can use GetTemplates() method of PageManager class. The method returns IQueryable<PageTemplate>.
Sincerely yours,
Ivan Dimitrov
the Telerik team
The GetTemplates() method hasnt been working for me, so this is what I did.
- the SF database, I did select * FROM sf_page_templates
- the id field has the guids for the templates in there, the title_ has the description
- in the code I did
- var templateGuid = new Guid("f669d9a7-009d-4d83-bbbb-000000000007");
To replace the following in the Fluent API example
var templateGuid = pManager.GetTemplates().First().Id;
hth
Hello Phillip,
I am not able to replicate any issues with GetTemplate method with the latest internal builds.
var manager = PageManager.GetManager();var templates = manager.GetTemplates();foreach (PageTemplate t in templates) var n = t.Name; var id = t.Id;Regarding my GetTemplates() issue, more info here
www.sitefinity.com/.../pagemanager-gettemplates-not-working.aspx
how do you set the template when you create a page?
the SetTemplate method isn't in the API anymore.
Hi,
Each PageData object has a property Template which you can use to set a template.
pagedata.Template = pageManager.GetTemplates().First();
pageManager.SaveChanges();
SiteMapBase.Cache.Flush();
Best wishes,
Ivan Dimitrov
the Telerik team