Can't create PageTemplate
Hello,
m_PageManager = PageManager.GetManager();
PageTemplate template = m_PageManager.CreateTemplate();
System.UnauthorizedAccessException: You are not authorized to 'Create 0' ('PageTemplates').
at DynamicModule.ns.Wrapped_OpenAccessPageProvider_4cd78ae30c8f42e0b41029957c79c297.CreateTemplate()
at Telerik.Sitefinity.Modules.Pages.PageManager.CreateTemplate()
at ............ :line 57
PageData pageData = m_PageManager.CreatePageData();
PageNode pageNode = m_PageManager.CreatePageNode();
Hi Lupi,
You are getting the error, because you are not logged in and you are trying to create a new template with an anonymous user. You have to grant "Anonymous" user "Create" permissions or suppress the security check.
var manager = PageManager.GetManager();
manager.Provider.SuppressSecurityChecks =
true
;
var template = manager.CreateTemplate(
new
Guid(
"DB253C06-DF25-42b3-8BF7-2CE022E53121"
));
template.Name =
"SampleTemplate2"
;
template.Title =
"SampleTemplate2"
;
manager.SaveChanges();
Telerik.OpenAccess.Exceptions.NoSuchObjectException: No row for Telerik.Sitefinity.News.Model.NewsItem ('sf_news_items') GenericOID@c54d4ae0 NewsItem content_id=e74a0fec-0607-450c-81ce-24eb1df3c676 NOTRES
at DynamicModule.ns.Wrapped_OpenAccessNewsProvider_3986aa31ddb24962bfe5c86a5a0b89c0.GetNewsItem(Guid id)
at Telerik.Sitefinity.Modules.News.NewsManager.GetNewsItem(Guid id)
at ....
Hello Lupi,
Try using the code below.
var item = App.WorkWith().NewsItem().ContentManager.GetItem(
typeof
(NewsItem),
new
Guid(
"76CFAEBD-E2BB-40B5-9670-C10C565B7830"
));
Thanks for the reply. I used the following code and it worked for me:
var items = newsManager.GetNewsItems().Where(t => t.Title == title && t.PublicationDate == publicationDate);
if (items.Count() > 0)
...
Guid id =
new
Guid(<my_source_guid>);
var items = newsManager.GetNewsItems().Where(t => t.Id == id);
if
(items.Count() > 0)
...