2016-04-22 34 views
1

我使用下面的代碼創建了元標題,但它適用於大多數我的網站,但一個特定的網站不會保存元標題,所以當我編輯時顯示我以前輸入的標題,相同的代碼對於所有的網站,但一個不節約?自定義銀條紋元字段不保存

class Page extends SiteTree { 

    private static $db = array(
     'MetaTitle' => 'Varchar(255)' 
    ); 

    private static $has_one = array(
    ); 

    public function getCMSFields() { 
     $fields = parent::getCMSFields(); 

     $fields->addFieldToTab('Root.Main', TextField::create('MetaTitle') 
       ->setRightTitle('Shown at the top of the browser window and used as the "linked text" by search engines.') 
       ->addExtraClass('help') 
      , 'MetaDescription'); 

     return $fields; 
    } 

} 
+0

你打電話給/ dev/build?flush = 1嗎?也許該字段不在你的db中 –

+0

@csy你是正確的,需要dev/buils和flush。 –

回答

0

如果在添加新的$ db屬性後沒有/ dev/build,更改將無法正確保存。