Coder Social home page Coder Social logo

Template Meta Issue about seomatic HOT 3 CLOSED

RichardAlbary avatar RichardAlbary commented on June 16, 2024
Template Meta Issue

from seomatic.

Comments (3)

khalwat avatar khalwat commented on June 16, 2024

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.

khalwat avatar khalwat commented on June 16, 2024

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.

RichardAlbary avatar RichardAlbary commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.