diff --git a/code/objects/Location.php b/code/objects/Location.php
index 6ed0358..1822af5 100644
--- a/code/objects/Location.php
+++ b/code/objects/Location.php
@@ -89,7 +89,6 @@ class Location extends DataObject implements PermissionProvider
'Phone',
'Email',
'Category.ID',
- 'ShowInLocator',
'Featured',
);
@@ -106,11 +105,17 @@ class Location extends DataObject implements PermissionProvider
'Postcode',
'Country',
'Category.Name',
- 'ShowInLocator.NiceAsBoolean',
'Featured.NiceAsBoolean',
'Coords',
);
+ /**
+ * @var array
+ */
+ private static $extensions = [
+ 'VersionedDataObject',
+ ];
+
/**
* Coords status for $summary_fields
*
@@ -164,24 +169,20 @@ public function getCMSFields()
->setAttribute('placeholder', 'http://'),
DropdownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))
->setEmptyString('-- select --'),
- CheckboxField::create('ShowInLocator', 'Show in results')
- ->setDescription('Location will be included in results list'),
CheckboxField::create('Featured')
->setDescription('Location will show at/near the top of the results list')
)
)
);
- // allow to be extended via DataExtension
- $this->extend('updateCMSFields', $fields);
+ $fields->removeByName([
+ 'ShowInLocator',
+ 'Import_ID',
+ ]);
// override Suburb field name
$fields->dataFieldByName('Suburb')->setTitle('City');
- $fields->removeByName(array(
- 'Import_ID',
- ));
-
return $fields;
}
diff --git a/code/pages/Locator.php b/code/pages/Locator.php
index fecc6a1..26b715d 100644
--- a/code/pages/Locator.php
+++ b/code/pages/Locator.php
@@ -167,9 +167,7 @@ class Locator_Controller extends Page_Controller
/**
* @var array
*/
- private static $base_filter = [
- 'ShowInLocator' => true,
- ];
+ private static $base_filter = [];
/**
* @var array
diff --git a/composer.json b/composer.json
index d0744a2..922caf6 100644
--- a/composer.json
+++ b/composer.json
@@ -23,6 +23,8 @@
"silverstripe/framework": "^3.4",
"silverstripe/cms": "^3.4",
"silverstripe-australia/addressable": "^1.1",
+ "heyday/silverstripe-versioneddataobjects": "^1.4",
+ "unclecheese/betterbuttons": "^1.3",
"muskie9/data-to-arraylist": "^1.0"
},
"suggest": {
diff --git a/tasks/LocationPublishTask.php b/tasks/LocationPublishTask.php
new file mode 100644
index 0000000..ed4d538
--- /dev/null
+++ b/tasks/LocationPublishTask.php
@@ -0,0 +1,42 @@
+publishLocations();
+ }
+ /**
+ * mark all ProductDetail records as ShowInMenus = 0.
+ */
+ public function publishLocations()
+ {
+ $locations = Location::get();
+ $ct = 0;
+ foreach ($locations as $location) {
+ if ($location->ShowInLocator == 1 && !$location->isPublished()) {
+ $title = $location->Title;
+ $location->writeToStage('Stage');
+ $location->publish('Stage', 'Live');
+ echo $title.'
';
+ ++$ct;
+ }
+ }
+ echo '
'.$ct.' locations updated.
'; + } +} \ No newline at end of file