WithCandour / statamic-aardvark-seo

Candour's SEO addon for Statamic
https://statamic.com/marketplace/addons/aardvark-seo
11 stars 18 forks source link

Conflict between Aardvark SEO tags and Yield tag #150

Open jasonbradberry opened 1 year ago

jasonbradberry commented 1 year ago

When I added the Aardvark SEO tags to my layout view, the yield tag I was using in that layout stopped working.

The Yield tag itself was rendering fallback content on the page, which seems to mean that there was a clash that was causing the Aardvark SEO tags to somehow cause the section content from within {{ template_content }} to not be pulled through into the Yield tag.

Here's my layout file (the Yield tag is in the header):

<!doctype html>
<html lang="{{ site:short_locale }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        {{ aardvark-seo:head }}
        <link rel="stylesheet" href="{{ mix src='css/site.css' }}">
        <link rel="stylesheet" href="https://use.typekit.net/jdv4ubh.css">
    </head>
    <body>
        {{ aardvark-seo:body }}
        <header class="header-bar {{ yield:header_color }}is-aqua{{ /yield:header_color }}">  
            <a href="#nav" class="nav-toggle">
                <div class="nav-toggle__dots">
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                </div>
                <span class="nav-toggle__text">Menu</span>
            </a>
        </header>
        …
        <script src="{{ mix src='/js/site.js' }}"></script>
        {{ aardvark-seo:footer }}
    </body>
</html>

And here's the corresponding Section tag from the page view file, which should be sending it's contents to the Yield tag to replace the fallback content:

{{ section:header_color }}is-lemon{{ /section:header_color }}

xuneXTW commented 1 year ago

We are experiencing the same problem here. Would be pretty improtant to fix this. Otherwise we are not able to use the plugin on the page.

xuneXTW commented 1 year ago

@AndrewHaine @jackwakefield The Problem seems to be here (Tags/AardvarkSeoTags.php, method: head)

    if (config('statamic.antlers.version') == 'regex') {
        $view = view('aardvark-seo::tags.head', $data);
    } else {
        $view = View::make('aardvark-seo::tags.head', $data->all());
    }

If i return the view with the helper function "view", all my sections will be rendered correctly. Just with the "View::make" implementation they will be cleared somehow.

AndrewHaine commented 1 year ago

Hi there,

Please could I confirm the following:

I'm currently unable to replicate this on a fresh Statamic 3.3.59 instance with Aardvark 2.0.30 with either the regex or runtime parser.

Thanks, Andrew

xuneXTW commented 1 year ago

Hi @AndrewHaine

Here are my details:

Environment
Application Name: zahnarztzentrum.ch
Laravel Version: 9.42.2
PHP Version: 8.1.6
Composer Version: 2.3.7
Environment: local
Debug Mode: OFF
URL: zahnarztzentrum.test
Maintenance Mode: OFF
Statamic
Addons: 5
Antlers: runtime
Version: 3.3.59 PRO

Statamic Addons
jacksleight/statamic-miniset: 0.3.1
parfaitementweb/statamic-country-fieldtype: 1.0.0
raynl/generate-slug: 1.1.1
rias/statamic-address-field: 1.0.3
withcandour/aardvark-seo: 2.0.30

The issue is kinda weird. If you add one yield / section-pair it works fine. We have 2 yield tags in the header and with the tag inserted in the header it will display only one of them. With the response changed to the "view()" helper it will display both of them.