mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Some work on page title generation including usage of the SiteName (site setting)
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044449
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Orchard.Core.Settings.Records;
|
||||
using Orchard.Core.Settings.Records;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<title><%=Html.Title("site name") %></title><%
|
||||
<title><%=Html.Title() %></title><%
|
||||
Html.Zone("head", ":metas :styles :scripts"); %>
|
||||
</head>
|
||||
<body><%
|
||||
|
@@ -4,7 +4,7 @@
|
||||
Html.RegisterStyle("site.css"); %>
|
||||
<div class="page">
|
||||
<div id="header">
|
||||
<div id="title"><h1>My MVC Application</h1></div><%
|
||||
<div id="title"><h1><%=Html.TitleForPage(Html.SiteName()) %></h1></div><%
|
||||
Html.Zone("header");
|
||||
Html.Zone("menu"); %>
|
||||
<%-- todo:(nheskew) this will need to all go in the header zone (user widget) --%>
|
||||
|
@@ -5,7 +5,7 @@ Html.RegisterStyle("site.css");
|
||||
%>
|
||||
<div class="page">
|
||||
<div id="header">
|
||||
<div id="title"><h1><%//Html.SiteName(); %></h1></div><%
|
||||
<div id="title"><h1><%=Html.TitleForPage(Html.SiteName()) %></h1></div><%
|
||||
Html.Zone("header");
|
||||
Html.Zone("menu"); %>
|
||||
<%-- todo:(nheskew) this will need to all go in the header zone (user widget) --%>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.UI;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
@@ -26,14 +25,27 @@ namespace Orchard.Mvc.Html {
|
||||
html.Resolve<IPageTitleBuilder>().AddTitleParts(titleParts);
|
||||
}
|
||||
|
||||
public static void AppendTitleParts(this HtmlHelper html, params string[] titleParts) {
|
||||
html.Resolve<IPageTitleBuilder>().AppendTitleParts(titleParts);
|
||||
}
|
||||
|
||||
public static MvcHtmlString Title(this HtmlHelper html, params string[] titleParts) {
|
||||
IPageTitleBuilder pageTitleBuilder = html.Resolve<IPageTitleBuilder>();
|
||||
|
||||
html.Resolve<IPageTitleBuilder>().AppendTitleParts(titleParts);
|
||||
html.AppendTitleParts(titleParts);
|
||||
|
||||
return MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateTitle()));
|
||||
}
|
||||
|
||||
public static MvcHtmlString TitleForPage(this HtmlHelper html, params string[] titleParts) {
|
||||
if (titleParts == null || titleParts.Length < 1)
|
||||
return null;
|
||||
|
||||
html.AppendTitleParts(titleParts);
|
||||
|
||||
return MvcHtmlString.Create(html.Encode(titleParts[0]));
|
||||
}
|
||||
|
||||
public static void Zone<TModel>(this HtmlHelper<TModel> html, string zoneName, string partitions) where TModel : BaseViewModel {
|
||||
IZoneManager manager = html.Resolve<IZoneManager>();
|
||||
|
||||
|
10
src/Orchard/Mvc/Html/SiteServiceExtensions.cs
Normal file
10
src/Orchard/Mvc/Html/SiteServiceExtensions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class SiteServiceExtensions {
|
||||
public static string SiteName(this HtmlHelper html) {
|
||||
return html.Resolve<ISiteService>().GetSiteSettings().SiteName;
|
||||
}
|
||||
}
|
||||
}
|
@@ -186,6 +186,7 @@
|
||||
<Compile Include="Mvc\Filters\AdminFilter.cs" />
|
||||
<Compile Include="IOrchardServices.cs" />
|
||||
<Compile Include="Mvc\Html\FileRegistrationContext.cs" />
|
||||
<Compile Include="Mvc\Html\SiteServiceExtensions.cs" />
|
||||
<Compile Include="Themes\ExtensionManagerExtensions.cs" />
|
||||
<Compile Include="Extensions\Helpers\PathHelpers.cs" />
|
||||
<Compile Include="Extensions\IExtensionManager.cs" />
|
||||
|
@@ -12,16 +12,14 @@ namespace Orchard.UI.PageTitle {
|
||||
_titleSeparator = " - ";
|
||||
}
|
||||
|
||||
public void AddTitleParts(params string[] titleParts)
|
||||
{
|
||||
public void AddTitleParts(params string[] titleParts) {
|
||||
if (titleParts != null)
|
||||
foreach (string titlePart in titleParts)
|
||||
if (!string.IsNullOrEmpty(titlePart))
|
||||
_titleParts.Add(titlePart);
|
||||
}
|
||||
|
||||
public void AppendTitleParts(params string[] titleParts)
|
||||
{
|
||||
public void AppendTitleParts(params string[] titleParts) {
|
||||
if (titleParts != null)
|
||||
foreach (string titlePart in titleParts)
|
||||
if (!string.IsNullOrEmpty(titlePart))
|
||||
|
Reference in New Issue
Block a user