mojoportal学习——文章翻译之layout.master文件

翻译的不好 大家见谅.

 

layout.master文件

layout.master是所有页面的模板,每一个页面上的标签都应该存在于layout.master文件中。

在layout.master文件中,有许多需要的标签,用来呈现数据库中的数据。你可以添加自定义的标签用以显示

你的内容。风格和布局是由css文件控制的。你会发现很少的不同在不通的皮肤模板中。


>>mojoportal layout.master中需要的元素

没有这些元素,站点就不能工作。另外,必须包含标准的html头,和body元素 , 另外推荐包含Doctype元素.

以下是一个包含最少元素的layout.master文件

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="~/App_MasterPages/layout.Master.cs" Inherits="mojoPortal.Web.layout" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server"><title></title>
</head>
<body class="pagebody">
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="SiteMapData" runat="server" ShowStartingNode="false" />
<asp:SiteMapDataSource ID="ChildPageSiteMapData" runat="server" ShowStartingNode="false" />
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
<portal:SiteMenu id="SiteMenu1" runat="server" UseTreeView="false" HideMenuOnSiteMap="false" Direction="Horizontal" ></portal:SiteMenu>
<asp:Panel id="divLeft" runat="server" cssclass="leftside" visible="True" SkinID="pnlPlain">
 <asp:contentplaceholder ID="leftContent" runat="server"></asp:contentplaceholder>
</asp:Panel>
<asp:Panel id="divCenter" runat="server" visible="True" cssclass="center-rightandleftmargins" SkinID="pnlPlain">
 <asp:ContentPlaceHolder ID="mainContent" runat="server"></asp:ContentPlaceHolder>
</asp:Panel>
<asp:Panel id="divRight" runat="server" visible="True" cssclass="rightside" SkinID="pnlPlain">
  <asp:contentplaceholder ID="rightContent" runat="server"></asp:contentplaceholder>
</asp:Panel>
<asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>
</form>
</body>
</html>

建议在新建模板时,从已有的模板中拷贝layout.master文件过来。

SiteMapDataSource  用于显示菜单

ScriptManager  微软AjAx框架需要

LoginLink   登录连接,用户没有登陆时显示

LogoutLink  用户登录后显示

contentplaceholder id=pageEditContent
对编辑用户显示编辑标签

SiteMenu  站点主菜单  最重要的设置是Direction. 可以横向或纵向.

Panel id=divLeft 左侧布局列

panel id=divCenter 中间布局列

panel id=divRight 右侧布局列

>>>>推荐的layout.master元素

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="~/App_MasterPages/layout.Master.cs" Inherits="mojoPortal.Web.layout" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server"><title></title>
    <portal:StyleSheetCombiner id="StyleSheetCombiner" runat="server" JQueryUIThemeName="trontastic" UseIconsForAdminLinks="false" />
    <portal:IEStyleIncludes id="IEStyleIncludes1" runat="server" IncludeHtml5Script="true" />
    <portal:MetaContent id="MetaContent" runat="server" />
 <portal:Favicon id="Favicon1" runat="server" />
 <portal:ScriptLoader id="ScriptLoader1" runat="server" />
</head>
<body class="pagebody">
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="SiteMapData" runat="server" ShowStartingNode="false" />
<asp:SiteMapDataSource ID="PageMapDataSource" runat="server" ShowStartingNode="false" />
<asp:SiteMapDataSource ID="ChildPageSiteMapData" runat="server" ShowStartingNode="false" />
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
<div id="wrapwebsite">
    <div class="topnav">
        <portal:SkipLink id="SkipLink1" runat="server" />
        <ul>
        <portal:WelcomeMessage id="WelcomeMessage" runat="server" RenderAsListItem="true" ListItemCSS="firstnav" />
        <portal:HomeLink id="HomeLink" runat="server" RenderAsListItem="true" />
        <portal:SiteMapLink id="SiteMapLink2" runat="server" CssClass="sitelink" RenderAsListItem="true" />
        <portal:MyPageLink id="MyPageLink1" runat="server" RenderAsListItem="true" />
        <portal:UserProfileLink id="UserProfileLink" runat="server" RenderAsListItem="true" />
        <portal:MailboxLink id="MailboxLink1" runat="server" RenderAsListItem="true" />
        <portal:MemberListLink id="MemberListLink" runat="server" RenderAsListItem="true" />
        <portal:SearchInput id="SearchInput1" LinkOnly="True" RenderAsListItem="true" runat="server" />
        <portal:RegisterLink id="RegisterLink" runat="server" RenderAsListItem="true" />
        <portal:LoginLink id="LoginLink" runat="server" RenderAsListItem="true" />
        <portal:LogoutLink id="LogoutLink" runat="server" RenderAsListItem="true" />
        </ul>
</div>
<div id="wrapheader">
<portal:SiteTitle id="SiteTitle" runat="server"></portal:SiteTitle>
</div>
<portal:SiteMenu id="SiteMenu1" runat="server" EnableTheming="false"
UseTreeView="false" HideMenuOnSiteMap="false"
Direction="Horizontal" TopLevelOnly="true"></portal:SiteMenu>
<div id="wrapcenter">
<asp:Panel id="divLeft" runat="server" cssclass="leftside" visible="True" SkinID="pnlPlain">
<portal:PageMenu id="PageMenu1" runat="server" UseTreeView="true" TreeViewShowExpandCollapse="true" />
<a id="startcontent"></a>
<asp:contentplaceholder ID="leftContent" runat="server"></asp:contentplaceholder>
</asp:Panel>
<asp:Panel id="divCenter" runat="server" visible="True" cssclass="center-rightandleftmargins" SkinID="pnlPlain">
<portal:Breadcrumbs id="Breadcrumbs" runat="server"></portal:Breadcrumbs>
<portal:ChildPageMenu id="ChildPageMenu" runat="server" CssClass="txtnormal"></portal:ChildPageMenu>
<asp:ContentPlaceHolder ID="mainContent" runat="server"></asp:ContentPlaceHolder>
</asp:Panel>
<asp:Panel id="divRight" runat="server" visible="True" cssclass="rightside" SkinID="pnlPlain">
<asp:contentplaceholder ID="rightContent" runat="server"></asp:contentplaceholder>
</asp:Panel>
</div>
<div id="wrapfooter">
<portal:SiteMapLink id="SiteMapLink1" runat="server" CssClass="sitemaplink" /> |
<portal:SkinPreview id="SkinPreview1" runat="server"></portal:SkinPreview> |
<portal:CopyrightLabel ID="cl1" runat="server" ShowYear="true" BeginYear="2008" /> |
<portal:mojoPortalLink id="lnkmojoportal" runat="server" UseImage="false" /> |
<portal:XhtmlValidatorLink id="lnkw3cValidator" runat="server" UseImage="false" Html5="true" /> |
<portal:CSSValidatorLink id="lnkCSSVal1" runat="server" UseImage="false" /> |
<a title="Visit the web site of the designer" href="design" _mce_href="http://www.dcarter.co.uk">design">http://www.dcarter.co.uk">design by dcarter</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("span.downarr a").click(function() {
$("#toolbar").fadeOut();
$("#toolbarbut").fadeIn("slow");
});
$("span.showbar a").click(function() {
$("#toolbar").fadeIn();
$("#toolbarbut").fadeOut("slow");
});
$("span.downarr a, span.showbar a").click(function() {
return false;
});
});
</script>
<portal:AutoHidePanel ID="ah1" runat="server">
<div id="toolbarbut">
<span class="showbar"><a href="#">show bar</a></span>
</div>
<div id="toolbar">
<div class="toolbarleft">
&nbsp;
</div>
<div class="toolbarright">
<span class="downarr">
<a href="#"></a>
</span>
<portal:AdminMenuLink id="lnkAdminMenu" runat="server" />
<portal:FileManagerLink id="lnkFileManager" runat="server" />
<portal:NewPageLink id="lnkNewPage" runat="server" />
<portal:PageEditFeaturesLink id="lnkPageContent" runat="server" />
<portal:PageEditSettingsLink id="lnkPageSettings" runat="server" />
<asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>
</div>
</div>
</portal:AutoHidePanel>
<portal:mojoGoogleAnalyticsScript ID="mojoGoogleAnalyticsScript1" runat="server" />
<portal:Woopra ID="woopra11" runat="server" />
</form>
</body>
</html>


StylesheetCombiner 取得正确的风格地址,在head选区中

MetaContent     放在head选区中

Favicon         站点图片

WelcomeMessage 

HomeLink    

SiteMapLink

MyPageLink

UserProfileLink

MailboxLink

MemberlistLink

RegisterLink

SearchInput

SiteLogo

SiteTitle

SkipLink

BreadCrumbs

ChildPageMenu

SkinPreview

.......

posted on 2010-10-17 15:28  蓝蓝的天2016  阅读(385)  评论(0编辑  收藏  举报