2011-12-07 27 views

回答

2

如果你不想修改源,這裏有一個向下&骯髒的方式使用ApplicationBase注入來禁用它的一些jQuery的:

public class RemoveToolbarButtons : ApplicationBase 
{ 
    public RemoveToolbarButtons() 
    { 
     umbracoPage.Load += new umbraco.presentation.masterpages.MasterPageLoadHandler(umbracoPage_Load); 
    } 

    void umbracoPage_Load(object sender, EventArgs e) 
    { 
     var page = (umbracoPage)sender; 

     if (page.Page.Request.Path.ToLower().Replace((GlobalSettings.Path + "/").ToLower(), "").Contains("editcontent.aspx")) 
     { 
      var currentDocId = Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]); 
      Document d = new Document(currentDocId); 
      if (d.ContentType.Alias == "YourDocTypeAlias") 
      { 
       string s = @"<script type='text/javascript'> 
       $(document).ready(function() { 
        $('.editorIcon').each(function() { if(String($(this).attr('alt')) == 'Save and publish') {$(this).hide(); return false;} }); 
       }); 
       </script>"; 
       page.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "jshidetoolbar", s); 
      } 

     } 

    } 
} 

更改YourDocTypeAlias到doctypealias在那裏你想要禁用它。注意這只是使用jQuery隱藏按鈕,用戶仍然可以通過上下文菜單或其他方法訪問Publish。

0

Umbraco的完整源代碼可用作開源項目,所以是的,您可以禁用保存和發佈(並執行任何其他任何你想要的)。

Link

1

小調整湯姆的方法 - 調整了jQuery後不返回false(否則它只是隱藏了第一個「保存併發布」按鈕,當你有多個選項卡)

string s = @"<script type='text/javascript'> 
       $(document).ready(function() { 
        $('.editorIcon').each(function() { if(String($(this).attr('alt')) == 'Save and publish') {$(this).hide(); } }); 
       }); 
       </script>";