Silverstripe 将旧的银条形状转换为SS3
我有一个旧的SS2.4站点,我已将其更新为SS3.1.13。旧站点中我唯一无法使用的部分是过滤数据对象的搜索表单。旧代码是:Silverstripe 将旧的银条形状转换为SS3,silverstripe,Silverstripe,我有一个旧的SS2.4站点,我已将其更新为SS3.1.13。旧站点中我唯一无法使用的部分是过滤数据对象的搜索表单。旧代码是: public function doCollectionSearch($data, $form) { $filters = array(); ... //setup some filters based on user selections ... $where = implode(" AND ", $filters);
public function doCollectionSearch($data, $form)
{
$filters = array();
...
//setup some filters based on user selections
...
$where = implode(" AND ", $filters);
if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
$limit = $_REQUEST['start'].",50";
return $this->customise(array(
'Collections' => DataObject::get("Collection", $where, "Genus, Species ASC", null, $limit)
))->renderWith(array('Collection_results','Page'));
}
我已将最后一部分更新为:
return $this->customise(array(
'Collections' => Collection::get()->where($where)->sort("Genus, Species ASC")->limit($limit)
))->renderWith(array('Collection_results','Page'));
但我得到一个“CollectionPage_Controller”上不存在方法“fortemplate”
我知道$where还不正确,但是如果我去掉它,我仍然会得到一个错误
我知道我遗漏了一些明显的东西……有人能提出解决方案吗?如果模板访问的方法或数据库字段返回的对象不能简化为字符串,则会出现该错误。当您有一个相关对象(例如父页面)并执行以下操作时,通常会发生这种情况:
<p>My parent is: $Parent</p>
我的父母是:$parent
而不是
<p>My parent is: $Parent.Title</p>
我的父母是:$parent.Title
2.4中也存在同样的问题,因此这并不能完全解释您的问题,但我会在您的模板中查找类似于上述场景的内容。如果您的模板访问的方法或数据库字段返回的对象不能简化为字符串,则会出现该错误。当您有一个相关对象(例如父页面)并执行以下操作时,通常会发生这种情况:
<p>My parent is: $Parent</p>
我的父母是:$parent
而不是
<p>My parent is: $Parent.Title</p>
我的父母是:$parent.Title
2.4中也存在同样的情况,所以这并不能完全解释您的问题,但我会在您的模板中寻找类似上述场景的内容