Skip to content

Commit

Permalink
Changed so publications can be directly added to the archive.
Browse files Browse the repository at this point in the history
  • Loading branch information
colintucker committed Aug 22, 2018
1 parent 6f44335 commit 690d230
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
36 changes: 34 additions & 2 deletions src/Pages/PublicationArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class PublicationArchive extends Page implements ListSource
* @config
*/
private static $allowed_children = [
PublicationCategory::class
PublicationCategory::class,
Publication::class
];

/**
Expand Down Expand Up @@ -229,7 +230,23 @@ public function fieldLabels($includerelations = true)
*/
public function getPublications()
{
return $this->getSortedPublications(Publication::get()->filter('ParentID', $this->AllChildren()->column('ID') ?: null));
$publications = ArrayList::create();

$publications->merge(Publication::get()->filter('ParentID', $this->AllChildren()->column('ID') ?: null));

$publications->merge($this->getChildMembers());

return $this->getSortedPublications($publications);
}

/**
* Answers a list of the immediate child publications of the archive.
*
* @return DataList
*/
public function getChildPublications()
{
return $this->getSortedPublications($this->AllChildren()->filter('ClassName', Publication::class));
}

/**
Expand Down Expand Up @@ -288,6 +305,21 @@ public function getVisibleCategories()
return $data;
}

/**
* Answers the child publication list component for the template.
*
* @return BaseListComponent
*/
public function getChildPublicationList()
{
$list = clone $this->getListComponent();

$list->setSource($this->getChildPublications());
$list->setStyleIDFrom($this);

return $list;
}

/**
* Answers the publication list component for the template.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<% include Page\Image %>
<% include Page\Content %>
<% include SilverWare\Publications\Pages\PublicationArchive\Categories %>
<% include SilverWare\Publications\Pages\PublicationArchive\Publications %>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@
</article>
<% end_loop %>
</div>
<% else %>
<% include Alert Type='warning', Text=$NoDataMessage %>
<% end_if %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if $ChildPublications %>
<div class="publications">
$ChildPublicationList
</div>
<% end_if %>

0 comments on commit 690d230

Please sign in to comment.