silverstripe/silverstripe-blog

Minutes to read doesn't work with Elemental

Opened this issue · 0 comments

ec8or commented

I'm using Elemental blocks which causes the minutes to read to stop working as there's no "Content" field. Had to do this to get the word count from the blocks instead:

        $wordCount = 0;
        if ($this->owner->ElementalArea()->exists()) {
            $elementalArea = $this->owner->ElementalArea();
            foreach($elementalArea->Elements() as $element) {
                $wordCount += str_word_count(strip_tags($element->HTML));
            }
        }

This would obviously depend on what sort of blocks people are using so might just push the issue along but wondering if worth cleaning this up a bit and use if ElementalPageExtension is active? Or at least include a mention of it in the docs.