參考影片: sitefinity官網
自訂模組的功能需要特定權限才可以進行開發。
在settings中,有自訂模組的功能,定義模組(usercontrol)的路徑。
設定好模組後,在頁面設定的功能,Custom下就可以選到自定義的模組。
Demo:
後臺內容管理:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
using Telerik.Sitefinity; | |
namespace SitefinityWebApp.custom | |
{ | |
public partial class ucBlog : System.Web.UI.UserControl | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
if (Page.IsPostBack) | |
return; | |
} | |
protected void btnCreateBlog_Click(object sender, EventArgs e) | |
{ | |
Telerik.Sitefinity.App.WorkWith().Blog().CreateNew().Do(b => b.Title = "My New Blog").SaveChanges(); | |
} | |
protected void btnCreatePosts_Click(object sender, EventArgs e) | |
{ | |
using (var fluent = App.WorkWith()) | |
{ | |
var blog = (from b in fluent.Blogs() | |
where b.Title == "My New Blog" | |
select b).First(); | |
for (int i = 0; i < 10; i++) | |
{ | |
blog.CreateBlogPost().Do(p => p.Title = "Blog Post" + i).SaveChanges(); | |
} | |
} | |
} | |
protected void DisplayPosts_Click(object sender, EventArgs e) | |
{ | |
var posts = from p in App.WorkWith().BlogPosts() | |
where p.Parent.Title == "My New Blog" | |
orderby p.Title | |
select p; | |
this.gvList.DataSource = posts.Get(); | |
this.gvList.DataBind(); | |
} | |
} | |
} |
沒有留言:
張貼留言