diff --git a/src/Extensions/ElementalPageExtension.php b/src/Extensions/ElementalPageExtension.php index 66f1bde96..6a515c520 100644 --- a/src/Extensions/ElementalPageExtension.php +++ b/src/Extensions/ElementalPageExtension.php @@ -3,6 +3,7 @@ namespace DNADesign\Elemental\Extensions; use DNADesign\Elemental\Models\ElementalArea; +use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Control\Controller; use SilverStripe\View\Parsers\HTML4Value; use SilverStripe\View\SSViewer; @@ -31,6 +32,25 @@ class ElementalPageExtension extends ElementalAreasExtension * @return string */ public function getElementsForSearch() + { + return strip_tags($this->createHtml()); + } + + /** + * @param array $anchors + * + * @see SiteTree::getAnchorsOnPage() + */ + public function updateAnchorsOnPage(array &$anchors): void + { + if (!($this->owner instanceof SiteTree)) { + return; + } + $content = $this->createHtml(); + $anchors = array_merge($anchors, $this->owner->getAnchorsInContent($content)); + } + + private function createHtml() { $oldThemes = SSViewer::get_themes(); SSViewer::set_themes(SSViewer::config()->get('themes')); @@ -43,7 +63,7 @@ public function getElementsForSearch() /** @var ElementalArea $area */ $area = $this->owner->$key(); if ($area) { - $output[] = strip_tags($area->forTemplate()); + $output[] = $area->forTemplate(); } } } finally {