Comments (3)
So it's very likely you're running into a Twig scoping issue. When you {% include %}
a template, it's given a copy of the current Twig context (variables, etc.), which means that any changes made there are not propagated back to the parent template.
So for instance if you {% include %}
a template that changes some SEOmatic variables, they will not be changed in the parent context's scope.
It's just how Twig works.
So you'll either need to use extends
or embed
http://twig.sensiolabs.org/doc/tags/extends.html
http://twig.sensiolabs.org/doc/tags/embed.html
from seomatic.
I added this to the README.md:
Important: Due to the way Twig scoping works, if you {% include %}
a template, it's given a copy of the current Twig context (variables, etc.), which means that any changes made there are not propagated back to the parent template.
So for instance if you {% include %}
a template that changes some SEOmatic variables, they will not be changed in the parent context's scope, so they will not be rendered by SEOmatic.
You'll need to modify the SEOmatic variables in a template that {% extends %}
the main layout.twig
template or via Twig embeds
.
from seomatic.
Many thanks for your help on this. Hopefully I should be on the right track now!
Kind regards,
Richard Chalkley
MA BA(Hons) PROJECT MANAGER
6 JOLLIFFE'S COURT • 51-57 HIGH STREET • WIVENHOE • COLCHESTER • ESSEX • CO7 9AZ
TEL: +44 (0)1206 585200 • EMAIL: [email protected] mailto:[email protected] • WEB: SPIFFINGCOVERS.COM http://spiffingcovers.com/
The information provided in the email is to be treated as confidential and may not be used or disclosed except for the purpose for which it has been sent. If you are not the named recipient or have reason to believe that you are not the intended recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium. Although this email and any attachments are believed to be free from any virus or other defect which might affect any system into which they are opened or received, it is the responsibility of the recipient to check that they are virus free and that they will in no way affect systems and data. No responsibility is accepted by SpiffingCovers.com http://spiffingcovers.com/ Ltd. for any loss or damage arising in any way from their receipt, opening or use. Any views or opinions expressed are those of the individual sender and do not necessarily represent the view of SpiffingCovers.com http://spiffingcovers.com/ Ltd, its subsidiaries or associates. VAT Registration No. 158 6202 06
On 4 Mar 2016, at 18:09, khalwat [email protected] wrote:
So it's very likely you're running into a Twig scoping issue. When you {% include %} a template, it's given a copy of the current Twig context (variables, etc.), which means that any changes made there are not propagated back to the parent template.
So for instance if you {% include %} a template that changes some SEOmatic variables, they will not be changed in the parent context's scope.
It's just how Twig works.
So you'll either need to use extends or embed
http://twig.sensiolabs.org/doc/tags/extends.html http://twig.sensiolabs.org/doc/tags/extends.html
http://twig.sensiolabs.org/doc/tags/embed.html http://twig.sensiolabs.org/doc/tags/embed.html
—
Reply to this email directly or view it on GitHub #37 (comment).
from seomatic.
Related Issues (20)
- Sitemaps issue with multisite
- Enabling robots in devMode/local
- Overriding seomatic.meta.robots value has no effect on <meta> tag (in production environment) HOT 1
- Referrer-Policy should be updated
- Trying to get property 'sourceName' of non-object when clicking breadcrumb in seo content HOT 3
- Turn off x-powered-by: SEOmatic
- turn off Automatic Render Enabled and manually render scripts HOT 1
- Google Analytics showing /actions/seomatic URLs for some reason
- “Internal server error” when piggybacking (in PHP) HOT 2
- Google Tag Manager code ends up in body instead of head HOT 1
- Environment Variables/Aliases not parsed for humans.txt, though proposed in Text Field HOT 1
- Provide data in a structured way on GraphQL endpoint HOT 2
- Can't retrieve (GQL) or save (control panel) humans template HOT 1
- Section Entries Not Populating to Content SEO and Sitemap.xml HOT 2
- Pagination for Sitemaps / Sitemap Indexes HOT 2
- Sitemap Page loads slowly HOT 1
- Seo images don't update mtime when asset settings are changed. HOT 3
- SEO Image Source > render output with overlay image, logo or watermark HOT 5
- Algolia search on docs website is returning 404s HOT 4
- Unknown property error when upgrading to Craft 4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seomatic.