Skip to content

Commit

Permalink
Add new footer menu list
Browse files Browse the repository at this point in the history
  • Loading branch information
minimalic committed May 21, 2024
1 parent d0ba177 commit a159033
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Extensions/SiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace minimalic\SiteTools\Extensions;

use SilverStripe\ORM\DataExtension;

use SilverStripe\ORM\ArrayList;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CheckboxField;

Expand Down Expand Up @@ -36,4 +37,29 @@ public function updateSettingsFields(FieldList $fields)
], "ShowInSearch");
}

/**
* Generates footer menu from 1st level pages
*
* @return ArrayList<SiteTree>
*/
public function getFooterMenu()
{
$pages = SiteTree::get()->filter([
"ShowInFooter" => 1,
"ParentID" => 0,
]);

$visiblePages = [];

if (isset($visiblePages)) {
foreach ($pages as $page) {
if ($page->canView()) {
$visiblePages[] = $page;
}
}
}

return new ArrayList($visiblePages);
}

}

0 comments on commit a159033

Please sign in to comment.