0

データオブジェクトを複数の方法で使用する方法がわかりません。現在、1ページにしか表示できません。

cms でテーブルのアイテムを編集し、あるページにアイテムのリストを表示してから、別のページに特定のアイテムを表示できるようにしたいと考えています。

以下は、ページ内のすべてのクライアントを一覧表示し、CMS で編集できるように、これまでどのように構造化したかです。「clientPage」以外のページに一覧表示することも、1 つのクライアントの詳細ビュー ページを表示することもできません。

class Clients extends DataObject {
 public static $db = array(
    //All the table columns
);

 // One-to-one relationship with profile picture
public static $has_one = array(
    'ProfilePicture' => 'Image',
    'ClientPage' => 'ClientPage'
);

// Summary fields

public static $summary_fields = array(
    'ProfilePicture.CMSThumbnail'=>'Picture',
    'FIRST_NAME'=>'First Name',
    'LAST_NAME'=>'Last Name',
    'EMAIL'=>'Email'
);

public function getCMSFields_forPopup() {

    // Profile picture field
    $thumbField = new UploadField('ProfilePicture', 'Profile picture');
    $thumbField->allowedExtensions = array('jpg', 'png', 'gif');


    // Name, Description and Website fields
    return new FieldList(
        //all the editable fields for the cms popup
    );
}
}

クライアントページ

class ClientPage extends Page{
    private static $has_many = array(
      'Clients'=>'Client'
    );
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Client', GridField::create(
            'Client',
            'Client List',
            $this->Clients(),
            GridFieldConfig_RecordEditor::create()
        ));

        return $fields;
    }
}

class ClientPage_Controller extends Page_Controller{
    public function init() {
        parent::init();
    }
}

同じデータ オブジェクトを使用してディレクトリ ページを作成しようとすると、機能しません

class ClientDirectoryPage extends Page {
    private static $has_many = array(
      'Clients'=>'Client'
    );
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        return $fields;
    }
}

class ClientDirectoryPage_Controller extends Page_Controller{
    public function init() {
        parent::init();
    }
}
4

1 に答える 1