2013-07-03 27 views
0

我在Kentico中有一個顯示來自自定義表格的數據的頁面。一個自定義表中的字段是頁面的標題,我無法弄清楚如何在顯示的頁面標題字段...kentico page title from custom table

<title></title> 

...標籤

我能得到最接近的事到它正在顯示的URI作爲標題,所以/宣傳/ 頁標題的一部分將創建的

<title>page-title</title> 

標題至極小於期望的原因有三:

  1. /宣傳/頁,標題會顯示標題爲頁面標題
  2. 破折號仍然存在從URL
  3. 從URI文本實際上只是表示在自定義的數據蛞蝓表(一個名爲programkey場)和並不總是相同數據的實際標題

(EDIT)

好感謝Raymond,有點摸索周圍,這是我發現了什麼作品(張貼在自定義表tr ansformation):

<script runat="server"> 
     private string Title { get; set;} 
     private string Description { get; set;} 
     private string Keywords { get; set;} 
        protected override void OnDataBinding(EventArgs e) 
        { 
      base.OnDataBinding(e); 
      // Get values from custom table 
      Title = DataBinder.Eval(this.DataItem, "seo_title").ToString(); 
      Description = DataBinder.Eval(this.DataItem, "seo_desc").ToString(); 
      Keywords = DataBinder.Eval(this.DataItem, "seo_keywords").ToString(); 
      // Set values in meta tags 
      CMSContext.CurrentTitle = Title; 
      CMSContext.CurrentDescription = Description; 
      CMSContext.CurrentKeyWords = Keywords; 
     } 
    </script> 

回答

1

這應該做的伎倆:

CMSContext.CurrentTitle = "asdasd"; 
+0

謝謝我試試它 –

+1

它的工作,omg謝謝!我不得不做一些額外的東西來讓它起作用,所以我把它包含在編輯中 –

2

您還可以創建一個custom macro中,你將使用API​​來獲取自定義表數據。然後,在頁面標題/元數據設置中使用此宏

相關問題