Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible solution for rendering when using Elemental #55

Open
jellygnite opened this issue Jul 17, 2020 · 1 comment
Open

possible solution for rendering when using Elemental #55

jellygnite opened this issue Jul 17, 2020 · 1 comment

Comments

@jellygnite
Copy link

jellygnite commented Jul 17, 2020

I noticed that the analysis in PageHealthExtension didn't take into account any Elemental blocks. I couldn't see how you would use the seoContentFields configuration so I tried rendering with the current theme.

public function getRenderedHtml() {
... 
$current_themes = SSViewer::get_themes();  // get current CMS theme
Requirements::clear(); // we only want the HTML, not any of the js or css
SSViewer::set_themes(SSViewer::config()->uninherited('themes'));
$this->renderedHtml = $controllerName::singleton()->render($this->owner);
Requirements::restore(); // put the js/css requirements back when we're done
SSViewer::set_themes($current_themes);  // reset current CMS theme when we're done
...
}
@Fremmedkar
Copy link

You can use seoContentFields by casting the result of getElementsForSearch in ElementalPageExtension as Text in your Page class

private static $casting = [
    'ElementalContent' => 'Text'
];

public function getElementalContent()
{
    return $this->hasExtension(ElementalPageExtension::class) ? $this->getElementsForSearch() : '';
}

public function seoContentFields()
{
    return [
        'Content',
        'ElementalContent'
    ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants