Un-hard code ViewState argument

This commit is contained in:
Damian Mooyman 2017-07-25 10:40:58 +12:00
parent db5f81d393
commit b0380d8766

View File

@ -838,7 +838,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$dateGroup->setTitle(_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited')); $dateGroup->setTitle(_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'));
// view mode // view mode
$viewMode = HiddenField::create('view', false, 'listview'); $viewMode = HiddenField::create('view', false, $this->ViewState('listview'));
// Create the Field list // Create the Field list
$fields = new FieldList( $fields = new FieldList(
@ -1307,9 +1307,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
} }
/** /**
* @param string $default
* @return string * @return string
*/ */
public function ViewState() public function ViewState($default = 'treeview')
{ {
$mode = $this->getRequest()->requestVar('view') $mode = $this->getRequest()->requestVar('view')
?: $this->getRequest()->param('Action'); ?: $this->getRequest()->param('Action');
@ -1318,7 +1319,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
case 'treeview': case 'treeview':
return $mode; return $mode;
default: default:
return 'treeview'; return $default;
} }
} }