EndPreviousNextEnd EndPrint This TopicEnd

Convert HTML to ASCX Template

If you already have an existing website that you want to convert to a Contegro CMS website, you can convert an HTML webpage to a Contegro ASCX Template by removing all HTML Header tags and inserting the following mandatory code examples.

 

Essentially you need to remove all code that will be handled by Contegro's Modules, such as; dynamic and fixed navigation, banners, images, dynamic lists etc (because Contegro is designed to do this for you) and add the Contegro Container code outlined below. Have a look at Mapping Containers to Templates and Mapping Modules to Templates to help you understand how you can do this within the Contegro Administration Console.

 

1.Remove all HTML header tags (Contegro will add this code in you. Edit Page Attributes for each page to add Title and Meta data)

<html>

<head>

<meta>

<title>

<body>
 

2.Add the following Mandatory Template Code at the top of your file

 

<%@ Control %>

<%@ Register TagPrefix="contegro" TagName="Container" Src="~/UserControls/Base/Container.ascx" %>

<script language="C#" runat="server">

//Script required to get application path of site for resolving source paths for images, scripts and stylesheets.

public string SitePath = string.Empty;

void Page_Load(object sender, System.EventArgs e) {if (Page.ResolveUrl("~")!="/"){SitePath =

Page.ResolveUrl("~");}else{SitePath = "";}}

</script>

 

3.Insert the following Container Code wherever you need a module. Refer to your Pre-planning as a guide.

 

<contegro:Container id="xxx" name="xxx" runat="server"></contegro:Container>

 

4.Give your containers ID's and Names that correspond to your Pre-planning (i.e. replace the xxx in the example above).
 

5.Add in extra non-functional DIV’s, purely for design purposes that you can style using CSS to replicate your proposed Design Visuals. See Template.css for more information.

 

6.Save your template in the Templates folder as Filename.ascx.
 

7.Then follow the steps to Create a New Template.

 

You shouldn't need to add any other HTML to ASCX files. 

Use Contegro Core Modules and Add-on Modules to add functionality. For example, the Custom Code Module can be used to add 3rd party controls such as Flash in the Templates manager. 

By keeping the control out of the ASCX file, you are giving the power to the administrator, as details can be changed later in the Contegro Administration Console rather than at HTML/ASCX level.

 

See also

Mapping Modules to Templates

Global Module Functionality

Layout and Structure

Topic Link