建体彩网|中彩网双色球连号|
?
快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

新蒲京澳門賭場網站:為BlogEngine的分類增加自定義Url別名功能

?

此次為BlogEngine的分類增添了自定義Url又名功能

改動教程:木子原創:http://www.moozi.net

http://www.moozi.net/archive/2008/08/06/BlogEngine-category-url-slug.aspx有疑問請留言,感謝

改動代碼:

BlogEngine.Core.Category.cs

在56行

private string _Title;

/**////

/// Gets or sets the Title or the object.

///

public string Title

...{

get ...{ return _Title; }

set

...{

if (_Title != value) MarkChanged("Title");

_Title = value;

}

}

后添加:

private string _Slug;

/**////

/// Gets or sets the Slug or the object.

///

public string Slug

...{

get ...{ return _Slug; }

set

...{

if (_Slug != value) MarkChanged("Slug");

_Slug = value新蒲京澳門賭場網站;

}

}

public Category(string title, string description,string slug)

...{

this.Id = Guid.NewGuid();

this._Title = title;

this._Description = description;

this._Slug = slug;

this.Parent = null;

}

改動BlogEngine.Core.Providers.Categories.cs的

public override void InsertCategory(Category category),

public override void UpdateCategory(Category category),

public override void DeleteCategory(Category category)這些措施中作響應的改動

foreach (Category cat in categories)

...{

writer.WriteStartElement("category");

writer.WriteAttributeString("id", cat.Id.ToString());

writer.WriteAttributeString("description", cat.Description);

writer.WriteAttributeString("parent", cat.Parent.ToString());

writer.WriteAttributeString("slug", cat.Slug.ToString());//新增添的Url又名

writer.WriteValue(cat.Title);

writer.WriteEndElement();

cat.MarkOld();

}

改動public override List FillCategories()措施:

category.Id = new Guid(node.Attributes["id"].InnerText);

category.Title = node.InnerText;

后添加

if (node.Attributes["slug"] != null)

category.Slug = node.Attributes["slug"].InnerText;

else

category.Slug = string.Empty;

改動BlogEngine.Core.Web.HttpModules.UrlRewrite.cs中的private static void RewriteCategory(HttpContext context, string url)

private static void RewriteCategory(HttpContext context, string url)

...{

string title = ExtractTitle(context, url);

foreach (Category cat in Category.Categories)

...{

//string legalTitle = Utils.RemoveIllegalCharacters(cat.Title).ToLowerInvariant();

string legalTitle = Utils.RemoveIllegalCharacters(cat.Slug).ToLowerInvariant();

if (title.Equals(legalTitle, StringComparison.OrdinalIgnoreCase))

...{

context.RewritePath(Utils.RelativeWebRoot + "default.aspx?id=" + cat.Id.ToString() + GetQueryString(context), false);

break;

}

}

}

改動BlogEngine.Web/App_Code/Controls/CategoryList.cs中private H新蒲京澳門賭場網站tmlGenericControl BindCategories()這個措施

129行開始:

HtmlAnchor anc = new HtmlAnchor();

//anc.HRef = Utils.RelativeWebRoot + "category/" + Utils.RemoveIllegalCharacters(key) + BlogSettings.Instance.FileExtension;

anc.HRef = Utils.RelativeWebRoot + "category/" + Utils.RemoveIllegalCharacters(GetSlug(new Guid(dic[key].ToString()))) + BlogSettings.Instance.FileExtension;

anc.InnerHtml = HttpUtility.HtmlEncode(key) + postCount;

anc.Title = "Category: " + key;

改動BlogEngine.Web/admin/pages/Categories.aspx

在"

"后添加:

在"

">

' />

"后添加:

' />

改動BlogEngine.Web/admin/pages/Categories.aspx.cs中 void btnAdd_Click(object sender, EventArgs e)這個措施

將Category cat = new Category(txtNewCategory.Text, description);改成

string slug = txtNewSlug.Text;

if (slug.Length > 255)

slug = slug.Substring(0, 255);

Ca新蒲京澳門賭場網站tegory cat = new Category(txtNewCategory.Text, description, slug);

改動 void grid_RowUpdating(object sender, GridViewUpdateEventArgs e)措施:

Guid id = (Guid)grid.DataKeys[e.RowIndex].Value;

TextBox textboxTitle = (TextBox)grid.Rows[e.RowIndex].FindControl("txtTitle");

TextBox textboxSlug = (TextBox)grid.Rows[e.RowIndex].FindControl("txtSlug");//新增添的

TextBox textboxDescription = (TextBox)grid.Rows[e.RowIndex].FindControl("txtDescription");

DropDownList ddlParent = (DropDownList)grid.Rows[e.RowIndex].FindControl("ddlParent");

Category cat = Category.GetCategory(id);

cat.Title = textboxTitle.Text;

cat.Slug = textboxSlug.Text;//新增添的

cat.Description = textboxDescription.Text;

if (ddlParent.SelectedValue == "0")

cat.Parent = null;

else

cat.Parent = new Guid(ddlPare新蒲京澳門賭場網站nt.SelectedValue);

cat.Save();

Response.Redirect(Request.RawUrl);

到這里就改動完成了,改新蒲京澳門賭場網站的器械有點多,對照煩,由于我盤算對BlogEngine進行對照多的改動,以是暫時不供給改動的文件下載,等感到改得差不多了再供給下載

免責聲明:以上內容源自網絡,版權歸原作者所有,如有侵犯您的原創版權請告知,我們將盡快刪除相關內容。

您可能還會對下面的文章感興趣:

建体彩网
体彩福建31选718197 天天重庆麻将下载安装 广东26选5最新开奖结果查询 山东群英会遗漏查询 2012天下足球直播 天虹娱乐群 48期河南22选5开奖公告 体彩超级大乐透走势图2 足球竞猜让分胜负规则 沈阳麻将单机版