在模板中包含输出数据对象管理器


Outputting DataObjectManager in template include

我已经按照这里的教程 http://doc.silverstripe.org/old/modules:dataobjectmanager 在我的CMS中创建了一个数据对象管理器。

在那里一切都运行良好,但是我在模板中输出它时遇到了问题。我的代码如下

<?php 
class InfoArea extends DataObject{ 
   static $db = array( 
      'Title' => 'Varchar(255)', 
      'Content' => 'HTMLText' 
   ); 
   static $has_one = array( 
      'ResortPage' => 'ResortPage' 
   ); 
   public function getCMSFields_forPopup(){ 
      return new FieldSet( 
         new TextField('Title'), 
         new SimpleTinyMCEField('Content') 
      ); 
   } 
}

度假村页面.php

....... 
static $has_many = array ( 
      "InfoAreas" => "InfoArea" 
   ); 
....... 
$fields->addFieldToTab("Root.Content.AdditionalInformation", 
         new DataObjectManager( 
         $this, 
         'InfoAreas', 
         'InfoArea', 
         array('Title' => 'Title','Content'=>'Content'), 
         'getCMSFields_forPopup' 
      )); 
........

我有一个模板"ResortPage.ss",其中包含"ResortInfo.ss"。我需要从这个包含文件中输出数据对象。

我已经尝试了以下内容,但它没有输出任何内容

<% control InfoArea %> 
   $Title 
   $Content 
<% end_control %>

我在这里做错了什么?

谢谢

我发现了这个问题。在度假村页面课程中,我有

static $has_many = array ( 
      "InfoAreas" => "InfoArea" 
   ); 

以及

static $has_one = array ( 
      "InfoAreas" => "InfoArea" 
   ); 

..误打误撞。我只需要has_many.