ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Difference between Global Variables and Snippets

December 14, 2009 5:07pm

Subscribe [5]
  • #1 / Dec 14, 2009 5:07pm

    nextwebmedia

    6 posts

    Can someone clarify/demonstrate the difference between the two.

  • #2 / Dec 14, 2009 5:09pm

    Ingmar

    29245 posts

    Snippets are parsed at an earlier stage and can themselves contain other EE tags, even PHP code.

  • #3 / Dec 25, 2009 9:18pm

    Mario Rodríguez

    72 posts

    For me is still not clear the difference.

    Can variables contain EE Tags aswell or only Text and HTML/CSS code?

    Could someone make a table showing the differences or give some examples of both in the praxis?

    Thanks 😊

  • #4 / Dec 25, 2009 9:28pm

    Mario Rodríguez

    72 posts

    I reply myself 😊

    I found this in the Docs:

    What is the difference between a Snippet and a User-defined Global Variable?

    Snippets are expanded at a very early stage on each template, making it possible for them to hold dynamic content, ExpressionEngine tags, other variables, PHP, etc. They shine when you need to reuse dynamic information, but don’t need the extra overhead of access control or separate preferences of an embedded template. User-defined Global Variables are the polar opposites, expanded at the very end of all template parsing, and should be used for static text, HTML, JavaScript, and other static content that would not affect other tags and variables on the template.

    So is clear.. Snippets ar for Dynamic CODE and EE Tags, and Global Varibles for Text - HTML,CSS, Javascript so static.

    You could have called it “Dynamic Snippets” it would be clearer 😊

    Thanks

  • #5 / Dec 25, 2009 10:39pm

    grrramps

    2219 posts

    Snippets are parsed at an earlier stage and can themselves contain other EE tags, even PHP code.

    I see where Snippets go. How are they invoked? How do you get the snippets into a template?

  • #6 / Dec 25, 2009 11:03pm

    russlipton

    305 posts

    Once defined under Design-Templates-Snippets, snippets are invoked within a template in the same manner as a global variable or custom field: {some-snippet}

  • #7 / Dec 25, 2009 11:14pm

    grrramps

    2219 posts

    Once defined under Design-Templates-Snippets, snippets are invoked within a template in the same manner as a global variable or custom field: {some-snippet}

    So, it’s just a copy and paste routine (at best), or type it in (based on memory)?

    Are snippets usable across multiple weblogs (sites)?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases