mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 21:13:35 +08:00
Adding the page title separator to site settings
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044450
This commit is contained in:
@@ -6,6 +6,10 @@ namespace Orchard.Core.Settings.Models {
|
|||||||
public sealed class SiteSettings : ContentPart<SiteSettingsRecord>, ISite {
|
public sealed class SiteSettings : ContentPart<SiteSettingsRecord>, ISite {
|
||||||
public static readonly ContentType ContentType = new ContentType { Name = "site", DisplayName = "Site Settings" };
|
public static readonly ContentType ContentType = new ContentType { Name = "site", DisplayName = "Site Settings" };
|
||||||
|
|
||||||
|
public string PageTitleSeparator {
|
||||||
|
get { return Record.PageTitleSeparator; }
|
||||||
|
set { Record.PageTitleSeparator = value; }
|
||||||
|
}
|
||||||
public string SiteName {
|
public string SiteName {
|
||||||
get { return Record.SiteName; }
|
get { return Record.SiteName; }
|
||||||
set { Record.SiteName = value; }
|
set { Record.SiteName = value; }
|
||||||
|
@@ -5,5 +5,6 @@ namespace Orchard.Core.Settings.Records {
|
|||||||
public virtual string SiteUrl { get; set; }
|
public virtual string SiteUrl { get; set; }
|
||||||
public virtual string SiteName { get; set; }
|
public virtual string SiteName { get; set; }
|
||||||
public virtual string SuperUser { get; set; }
|
public virtual string SuperUser { get; set; }
|
||||||
|
public virtual string PageTitleSeparator { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -27,7 +27,9 @@ namespace Orchard.Core.Settings.Services {
|
|||||||
SiteSettingsRecord record = _siteSettingsRepository.Fetch(x => x.SiteUrl == applicationName).FirstOrDefault();
|
SiteSettingsRecord record = _siteSettingsRepository.Fetch(x => x.SiteUrl == applicationName).FirstOrDefault();
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
ISite site = _contentManager.Create<SiteSettings>("site", item => {
|
ISite site = _contentManager.Create<SiteSettings>("site", item => {
|
||||||
|
item.Record.SiteName = "My Orchard Project Application";
|
||||||
item.Record.SiteUrl = applicationName;
|
item.Record.SiteUrl = applicationName;
|
||||||
|
item.Record.PageTitleSeparator = " - ";
|
||||||
});
|
});
|
||||||
return site;
|
return site;
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,14 @@ namespace Orchard.Core.Settings.ViewModels {
|
|||||||
get { return Site.ContentItem.Id; }
|
get { return Site.ContentItem.Id; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SiteName {
|
public string PageTitleSeparator
|
||||||
|
{
|
||||||
|
get { return Site.As<SiteSettings>().Record.PageTitleSeparator; }
|
||||||
|
set { Site.As<SiteSettings>().Record.PageTitleSeparator = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SiteName
|
||||||
|
{
|
||||||
get { return Site.As<SiteSettings>().Record.SiteName; }
|
get { return Site.As<SiteSettings>().Record.SiteName; }
|
||||||
set { Site.As<SiteSettings>().Record.SiteName = value; }
|
set { Site.As<SiteSettings>().Record.SiteName = value; }
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Core.Settings.ViewModels.SettingsIndexViewModel>" %>
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Core.Settings.ViewModels.SettingsIndexViewModel>" %>
|
||||||
|
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||||
<h2>
|
<h2>Edit Settings</h2>
|
||||||
Edit Settings</h2>
|
|
||||||
<%using (Html.BeginForm()) { %>
|
<%using (Html.BeginForm()) { %>
|
||||||
<%= Html.ValidationSummary() %>
|
<%= Html.ValidationSummary() %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -12,6 +10,11 @@
|
|||||||
<%=Html.EditorFor(x=>x.SiteName) %>
|
<%=Html.EditorFor(x=>x.SiteName) %>
|
||||||
<%=Html.ValidationMessage("SiteName", "*") %>
|
<%=Html.ValidationMessage("SiteName", "*") %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<%=Html.LabelFor(x => x.PageTitleSeparator) %>
|
||||||
|
<%=Html.EditorFor(x => x.PageTitleSeparator)%>
|
||||||
|
<%=Html.ValidationMessage("PageTitleSeparator", "*")%>
|
||||||
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<%=Html.LabelFor(x => x.SuperUser) %>
|
<%=Html.LabelFor(x => x.SuperUser) %>
|
||||||
<%=Html.EditorFor(x=>x.SuperUser) %>
|
<%=Html.EditorFor(x=>x.SuperUser) %>
|
||||||
@@ -19,8 +22,9 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<%=Html.EditorFor(s=>s.Id) %>
|
<%=Html.EditorFor(s=>s.Id) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% foreach (var e in Model.EditorModel.Editors) { %>
|
<% foreach (var e in Model.EditorModel.Editors) {
|
||||||
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
|
var editor = e;
|
||||||
|
%><%=Html.EditorFor(m => editor.Model, editor.TemplateName, editor.Prefix)%>
|
||||||
<% } %>
|
<% } %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input class="button" type="submit" value="Save" />
|
<input class="button" type="submit" value="Save" />
|
||||||
|
@@ -3,7 +3,8 @@ using Orchard.Settings;
|
|||||||
|
|
||||||
namespace Orchard.Mvc.Html {
|
namespace Orchard.Mvc.Html {
|
||||||
public static class SiteServiceExtensions {
|
public static class SiteServiceExtensions {
|
||||||
public static string SiteName(this HtmlHelper html) {
|
public static string SiteName(this HtmlHelper html)
|
||||||
|
{
|
||||||
return html.Resolve<ISiteService>().GetSiteSettings().SiteName;
|
return html.Resolve<ISiteService>().GetSiteSettings().SiteName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ namespace Orchard.Settings {
|
|||||||
/// Interface provided by the "settings" model.
|
/// Interface provided by the "settings" model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISite : IContent {
|
public interface ISite : IContent {
|
||||||
|
string PageTitleSeparator { get; }
|
||||||
string SiteName { get; }
|
string SiteName { get; }
|
||||||
string SuperUser { get; }
|
string SuperUser { get; }
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,18 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Orchard.Settings;
|
||||||
|
|
||||||
namespace Orchard.UI.PageTitle {
|
namespace Orchard.UI.PageTitle {
|
||||||
public class PageTitleBuilder : IPageTitleBuilder {
|
public class PageTitleBuilder : IPageTitleBuilder {
|
||||||
|
private readonly ISiteService _siteService;
|
||||||
private readonly List<string> _titleParts;
|
private readonly List<string> _titleParts;
|
||||||
private readonly string _titleSeparator;
|
private readonly string _titleSeparator;
|
||||||
|
|
||||||
public PageTitleBuilder() {
|
public PageTitleBuilder(ISiteService siteService) {
|
||||||
|
_siteService = siteService;
|
||||||
_titleParts = new List<string>(5);
|
_titleParts = new List<string>(5);
|
||||||
//TODO: (erikpo) Get this from a site setting
|
//TODO: (erikpo) Get this from a site setting
|
||||||
_titleSeparator = " - ";
|
_titleSeparator = _siteService.GetSiteSettings().PageTitleSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTitleParts(params string[] titleParts) {
|
public void AddTitleParts(params string[] titleParts) {
|
||||||
|
Reference in New Issue
Block a user