Back to Arcane SEO Support

rskog
rskog

After installing Arcane SEO and including it in the default layout using {% component 'seo' %} i get errors on both static pages and blog posts.

Error for blog post: Call to a member function getProperties() on array ----/plugins/arcane/seo/components/Seo.php line 27


if($this->page->page->hasComponent('blogPost')) // blog post
   {
            $post = $this->page['post'];
            $this->page['viewBag']->setProperties(array_merge($this->page->viewBag->getProperties(), $post->attributes, $post->arcane_seo_options));
   }

Error for a static page: Unknown "template_from_string" function. ---------/plugins/arcane/seo/components/seo/default.htm line 7


{% set robots = [
    viewBag.robot_index,
    viewBag.robot_follow,
    include(template_from_string(viewBag.robot_advanced)),
   ]
%}
rskog
rskog

I was able to fix the error in static pages by installing https://octobercms.com/plugin/vojtasvoboda-twigextensions. Apparently, the template_from_string function is not available by default. One must add the \Twig\Extension\StringLoaderExtension extension explicitly when creating the Twig environment.


$twig = new \Twig\Environment(...);
$twig->addExtension(new \Twig\Extension\StringLoaderExtension());

Anyway, the twigextensions addon fixes that. But the error for blog pages remains.

Last updated

Arcane
Arcane

rskog thank you for your feedback, I will be looking into fixing the blogpost pages error. And i will try adding the extension to the plugin via composer.json so users don't need to install twigextensions. When the fix is made i will update your post.

rskog
rskog

I was able to fix the error in the blog pages by editing line 27 in /plugins/arcane/seo/components/Seo.php

Original code throws an error:


$this->page['viewBag']->setProperties(array_merge($this->page->viewBag->getProperties(), $post->attributes, $post->arcane_seo_options));

This code works:


$this->page['viewBag']->setProperties(array_merge($this->page['viewBag']->getProperties(), $post->attributes, $post->arcane_seo_options));

In the working code I replaced page->viewBag width page['viewBag']

I'm not sure this is a viable fix (it might break something I'm not aware of), but it removes the fatal error and displays the blog page.

Arcane
Arcane

rskog, yes that is the fix that was needed, i have forgotten to change ->viewBag to ["viewBag"] and now the plugin fix is available. The VojtaSvoboda.TwigExtensions plugin will be installed with arcane.seo as dependency.

Thank you for your contribution, good eye!

If you are experiencing any more issues, just let me know.

1-5 of 5