Skip to content

Commit

Permalink
fix(page-element): Show archived parents
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco (Valandur) committed Oct 15, 2018
1 parent a6c01af commit 24cc58e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/PageElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ public function getAllSectionParents() {
foreach ($this->PageSections() as $section) {
$p = $section->Parent();
if (!$p || !$p->ID) {
// If our parent doesn't have an ID it's probably deleted/archived, so we just don't list it.
// TODO: Improve this to list the parent as "archived"
// If our parent doesn't have an ID it's probably deleted/archived.
$p = $archived = Versioned::get_latest_version($section->__ParentClass, $section->__ParentID);
$p->__PageSection = $section;
$p->__PageElementVersion = $section->Elements()->filter("ID", $this->ID)->First()->Version;
$p->__PageElementPublishedVersion = "Not published";
$parents->add($p);
continue;
}

Expand Down
8 changes: 7 additions & 1 deletion src/PageSectionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ public function RenderPageSection($name = "Main")
*/
public function getPublishState()
{
return DBField::create_field("HTMLText", $this->owner->latestPublished() ? "Published" : "Draft");
$stage = "Draft";
if ($this->owner->isPublished()) {
$stage = "Published";
} else if ($this->owner->isArchived()) {
$stage = "Archived";
}
return DBField::create_field("HTMLText", $stage);
}
}

0 comments on commit 24cc58e

Please sign in to comment.