Pagetemplate (ContentType)

From Sense/Net 6.0 Wiki

Jump to: navigation, search

PageTemplates in Sense/Net 6.0 are used to store basic graphic design elements in the structured form of Sense/Net Content Repository, users can create new PageTemplates by copy-pasting html codes into the binary field of this content's creation form.

Templates allow a Web designer to construct a more flexible site, which is easy to update, and provide consistency and continuity between pages. Templates can enhance productivity, allowing some members of the team to focus on the format of the pages, while other members of the team create new pages and revise the content without changing the formatted layout.

Any HTML page may be saved as a template. All you have to do is open a new template and paste the binary to the appropriate field, then click save.

<ContentType name="PageTemplate" parentType="File" handler="SenseNet.Portal.PageTemplate" xmlns="http://schemas.sensenet.hu/SenseNet/ContentRepository/ContentTypeDefinition">
  <Title>PageTemplate</Title>
  <Description>[PageTemplate description]</Description>
  <Icon>PageTemplate</Icon>
  <Fields>
    <Field name="MasterPageNode" type="Reference">
      <Title>MasterPageNode</Title>
      <Description>[MasterPageNode description]</Description>
      <Configuration>
        <AllowMultiple>true</AllowMultiple>
        <AllowedTypes>
          <Type>MasterPage</Type>
        </AllowedTypes>
      </Configuration>
    </Field>
  </Fields>
</ContentType>

In this picture below you can see how this New Pagetemplate dialog box looks like.

Image:Create_new_page_template_dialog.jpg

  • Sample HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<title></title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta http-equiv="imagetoolbar" content="no" />
		<link rel="stylesheet" type="text/css" href="/Root/System/Skins/XYSkin/css/xy.css" />
	</head>
	<body>
		<div id="mainMenuDiv">
			<snpe-zone PartChromeType="None" name="ContentZone1"></snpe-zone>
		</div>
		<snpe:PortalRemoteControl ID="RemoteControl1" runat="server" />
	</body>
</html>

You can use your favorite text or html editor to edit your file.

All you have to do in your page template is to define:

  • SNPE Zones and their parameters,
  • add the Portal Remote Control: it must be on the first level below the "body" tag in the HTML code of the page, as shown in the sample html code.
  • You can also add other ASP.NET controls.

When you are ready, please save your file as DemoPageTemplate.html.

Note: When the zone contains PartChromeType="None" parameter the portlets you add to the page will not have borders by default. If the zone's PartChromeType attribute is not set to "None", the portlets you add will be displayed with borders around them.

Note2: You may also check out the page templates that come with the install.

[edit] Uploading a Page Template

The next step is to upload the html file you created in the previous chapter to the /Root/System/PageTemplates folder in the Sense/Net Content Repository using the upload file method discussed in details here. The other option is to create a new Page Template in the Sense/Net Content Repository by using Content Explorer. In case of the first method you have to upload a file with an html extension, in the second case you can add any name without any extension.

If you upload a .png file with the same name (e.g. DemoPagetamplate.html.png) Content Explorer will display a small image of the page template when you are about to select a page template for a new page in your portal. If you want to avoid the .html extension in the name of the page template you have to use the Create Page Template method.

When you upload or create a page template in the Page Template folder a Master page will be generated automatically.

[edit] The things you have to be aware when creating a PageTemplate

  • You can not have a part of the html code commented out, if that part contains a zone.
  • There can be no more than one ID, or NAME. (it may sound trivial, but this occurs many times)
  • There can be no "_" or "space" characters in the name of the zone. It causes problems when editing Portlets.

[edit] Related pages

Personal tools