initbiz / seostorm-plugin

SEO Storm - ultimate SEO tool for OctoberCMS
MIT License
26 stars 14 forks source link

twig_template_from_string(): Argument #1 ($env) must be of type Twig\Environment, string given #82

Open jumpshotink opened 8 months ago

jumpshotink commented 8 months ago

After installing the SEO Storm plugin, I am getting this error when I load a front end page. I notice it is conflicting with the Twig Extensions plugin from Vojta Svoboda. Is there a way to resolve this?

twig_template_from_string(): Argument #1 ($env) must be of type Twig\Environment, string given, called in /modules/system/classes/MarkupExtensionItem.php on line 166

function twig_template_from_string(Environment $env, $template, string $name = null): TemplateWrapper

Thanks.

ogalbnafets commented 7 months ago

I have the same problem :(

EDIT: Changed the Twig Function for this plugin.

  1. Goto Plugin Folder
  2. Open Plugin.php, in function registerMarkupTags, edit template_from_string -> replace with example template_from_string_SEO
  3. open components/seo/social.htm, replace template_from_string with template_from_string_SEO
  4. Now expand component partial in your template and replace template_from_string with template_from_string_SEO, for example:
    {% set settings = seo.getSettings() %}
    <meta name="description" content="{{ include(template_from_string_SEO(seo.getDescription())) }}" />
    {% set canonical = include(template_from_string_SEO(seo.getSeoAttribute('canonical_url'))) %}
    <link rel="canonical" href="{{ seo.getCanonicalUrl(canonical) }}">

    {% if settings.enable_robots_meta %}
    {% set advancedRobots = include(template_from_string_SEO(seo.getSeoAttribute('robot_advanced'))) %}
    {% endif %}

    {% if settings.enable_og %}
    {% partial '@social.htm' settings=settings %}
    {% endif %}
    {% if settings.extra_meta %}
    {{ settings.extra_meta|raw }}
    {% endif %}
Ladylain commented 1 month ago

Any news of InitBiz ? @tomaszstrojny @dzapek ?