Skip to content

Commit

Permalink
feat(page-element): Add tab with pages where element is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Crespi committed Jun 26, 2018
1 parent 35a57f1 commit 0793c1d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
9 changes: 9 additions & 0 deletions code/PageElement.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

class PageElement extends DataObject {
public static $singular_name = 'Element';
public static $plural_name = 'Elements';
Expand Down Expand Up @@ -99,6 +100,14 @@ public function getCMSFields() {
$fields->addFieldToTab('Root.PageSections', $this->getChildrenGridField());
}

$fields->addFieldsToTab("Root.Pages", ReadonlyField::create("Version", "Version", $this->Version));
$config = GridFieldConfig_Base::create()
->removeComponentsByType(GridFieldDataColumns::class)
->addComponent($dataColumns = new GridFieldDataColumns());
$dataColumns->setDisplayFields(["Title" => "Title", "getIsPublished" => "Is Published"]);
$gridField = GridField::create("Pages", "Pages", $this->Pages(), $config);
$fields->addFieldToTab("Root.Pages", $gridField);

return $fields;
}

Expand Down
4 changes: 4 additions & 0 deletions code/PageSectionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@ public function PageSection($name = "Main") {
array("Elements" => $elements, "ParentList" => strval($this->owner->ID))
);
}

public function getIsPublished() {
return DBField::create_field("HTMLText", $this->owner->latestPublished() ? "Published" : "Draft");
}
}
45 changes: 22 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"name": "flxlabs/silverstripe-pagesections",
"version": "0.1.6",
"description": "Adds configurable page sections and elements to your SilverStripe project.",
"type": "silverstripe-module",
"homepage": "http://github.com/flxlabs/silverstripe-pagesections",
"keywords": ["silverstripe", "sections", "elements", "page sections", "page elements"],
"license": "MIT",
"authors": [
{
"name": "Marco Crespi",
"email": "[email protected]"
}
],
"support": {
"issues": "http://github.com/flxlabs/silverstripe-pagesections/issues"
},
"require": {
"silverstripe/framework": "~3.6",
"flxlabs/silverstripe-versionedrelations": "^0.1.10"
},
"extra": {
"installer-name": "pagesections"
}
"name": "flxlabs/silverstripe-pagesections",
"version": "0.1.6",
"description": "Adds configurable page sections and elements to your SilverStripe project.",
"type": "silverstripe-module",
"homepage": "http://github.com/flxlabs/silverstripe-pagesections",
"keywords": ["silverstripe", "sections", "elements", "page sections", "page elements"],
"license": "MIT",
"authors": [{
"name": "Marco Crespi",
"email": "[email protected]"
}],
"support": {
"issues": "http://github.com/flxlabs/silverstripe-pagesections/issues"
},
"require": {
"silverstripe/framework": "~3.7",
"flxlabs/silverstripe-versionedrelations": "^0.1.14",
"symbiote/silverstripe-gridfieldextensions": "^2.0.2"
},
"extra": {
"installer-name": "pagesections"
}
}

0 comments on commit 0793c1d

Please sign in to comment.