Edit Built-in Page Templates in visual studio.
Hi Team,
I need to edit built-in basic page templates in visual studio. help me in either way,
1. How to edit basic page templates of sitefinity in visual studio (using thunder).
2. How to edit a custom page template in visual studio, which is created by using sitefinity basic template not by using the master page.
when im connecting sitefinity with thunder i can create and update new templates from visual studio and it only displays the list of page templates which is created from master page, and the sitefinity basic page templates are not displayed in sitefinity explorer / website templates. how can i solve my problem.
Thanks in advance.
Hello Prasanna,
There is no way for you to edit the default page templates other than through code. The templates you see in Sitefinity by default are build in the SiteInitializer class when your project is being created. For example here is the code for the 1 Column, Header, Footer template that ships with the product:
protected
virtual
void
Create1ColumnHeaderFooter(HierarchicalTaxon node,
short
ordinal,
bool
restoreToDefaultTemplate =
false
)
var template =
this
.GetTemplate(SiteInitializer.TemplateId1ColumnHeaderFooter, restoreToDefaultTemplate);
template.Name =
"OneColumnHeaderFooter"
;
Res.SetLstring(template.Title,
typeof
(PageResources),
"OneColumnHeaderFooter"
);
template.Category = node.Id;
template.Ordinal = ordinal;
var present =
this
.PageManager.CreatePresentationItem<TemplatePresentation>();
present.DataType = Presentation.HtmlDocument;
present.Name =
"master"
;
var resName =
"Telerik.Sitefinity.Resources.Pages.Frontend.aspx"
;
present.Data = ControlUtilities.GetTextResource(resName,
this
.assemblyInfo);
template.Presentation.Add(present);
present =
this
.PageManager.CreatePresentationItem<TemplatePresentation>();
present.DataType = Presentation.ImageUrl;
present.Name =
"icon"
;
present.Theme =
"Default"
;
present.Data =
"Telerik.Sitefinity.Resources.Themes.Default.Images.PageTemplates.1ColumnHeaderFooter.gif"
;
template.Presentation.Add(present);
var sibling = Guid.Empty;
var layout =
new
LayoutControl();
layout.Layout = ControlUtilities.ToVppPath(
"Telerik.Sitefinity.Resources.Templates.Layouts.Labeled.Column1TemplateHeader.ascx"
);
var ctrlData =
this
.PageManager.CreateControl<PageModel.TemplateControl>(
false
);
ctrlData.ObjectType = layout.GetType().FullName;
ctrlData.PlaceHolder =
"Body"
;
ctrlData.SiblingId = sibling;
sibling = ctrlData.Id;
ctrlData.Caption =
"Header"
;
ctrlData.Description =
"Represents the header of the template."
;
this
.PageManager.ReadProperties(layout, ctrlData);
this
.PageManager.SetControlId(template, ctrlData);
ctrlData.SetDefaultPermissions(
this
.PageManager);
template.Controls.Add(ctrlData);
layout =
new
LayoutControl();
layout.Layout = ControlUtilities.ToVppPath(
"Telerik.Sitefinity.Resources.Templates.Layouts.Labeled.Column1Template.ascx"
);
ctrlData =
this
.PageManager.CreateControl<PageModel.TemplateControl>(
false
);
ctrlData.ObjectType = layout.GetType().FullName;
ctrlData.PlaceHolder =
"Body"
;
ctrlData.SiblingId = sibling;
sibling = ctrlData.Id;
ctrlData.Caption =
"Content"
;
ctrlData.Description =
"Represents the content area of the template."
;
this
.PageManager.ReadProperties(layout, ctrlData);
this
.PageManager.SetControlId(template, ctrlData);
ctrlData.SetDefaultPermissions(
this
.PageManager);
template.Controls.Add(ctrlData);
layout =
new
LayoutControl();
layout.Layout = ControlUtilities.ToVppPath(
"Telerik.Sitefinity.Resources.Templates.Layouts.Labeled.Column1TemplateFooter.ascx"
);
ctrlData =
this
.PageManager.CreateControl<PageModel.TemplateControl>(
false
);
ctrlData.ObjectType = layout.GetType().FullName;
ctrlData.PlaceHolder =
"Body"
;
ctrlData.SiblingId = sibling;
sibling = ctrlData.Id;
ctrlData.Caption =
"Footer"
;
ctrlData.Description =
"Represents the footer of the template."
;
this
.PageManager.ReadProperties(layout, ctrlData);
this
.PageManager.SetControlId(template, ctrlData);
ctrlData.SetDefaultPermissions(
this
.PageManager);
template.Controls.Add(ctrlData);
this
.CreateTemplateInvariantLanguageData(template);