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.

snippets not being parsed

July 04, 2010 3:38am

Subscribe [6]
  • #1 / Jul 04, 2010 3:38am

    Craig Allen

    135 posts

    I’ve got a couple of sites I’m building in EE2 and have been having problems with snippets in both.

    Now and again a snippet will refuse to work and instead I will get the tag outputted literally - for example I created a snippet called top_nav. And when I put it into a template, but it outputted “{top_nav}” literally. This has happened a few times.

    Previously I’ve been able to solve it by creating a new snippet named something else, but with the content I want, then deleting the old snippet, then renaming the new one to the name of the old one.

    However, now on one of the sites that solution does not work because all new snippets I create now output the tag literally. If I put something else in as a substitute, such as a global variable like site_name it parses correctly. And it doesn’t matter what I put into the snippet. Even ‘xyz’ does not come through.

    What might be the cause please?

  • #2 / Jul 04, 2010 2:19pm

    Greg Salt

    3988 posts

    Hi Craig,

    Which version and build of EE2 PB are you using? Also, do you have any 3rd party addons installed in these sites?

    Cheers

    Greg

  • #3 / Jul 11, 2010 12:59am

    Craig Allen

    135 posts

    Hi Greg,

    You can see a test page here

    In an attempt to isolate whether any of the addons are the cause, I have disabled plugins and extensions, uninstalled all modules other than channels, jquery and member, and have uninstalled all accessories.

    I’ve worked out that is is something to do with nesting snippets.

    At the top of all my templates I have a snippet called {GLOBAL_START}

    This contains:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html >
    
    {global_html_head}
    {global_body_start}
    {global_page_header}

    i.e., there are sub-snippets.

    If in the pages/page template I remove the {GLOBAL_START} snippet and instead insert it’s contents directly, then those three sub-snippets - {global_html_head}, {global_body_start} and {global_page_header} - are parsed correctly.

    The {GLOBAL_END} snippet has the same problem.

    However the nested arrangement works on another site with both (GLOBAL_START} and {GLOBAL_END}. And with a third site {GLOBAL_START} works, but {GLOBAL_END} doesn’t!

  • #4 / Jul 11, 2010 4:02pm

    Greg Salt

    3988 posts

    Hi Craig,

    Can you please post what each of global_html_head, global_body_start and global_page_header contain?

    Cheers

    Greg

  • #5 / Jul 12, 2010 1:25pm

    Craig Allen

    135 posts

    {global_html_head}

    <head>
      <title>{site_name}</title>
      <meta http-equiv="content-type" content="text/html;charset=utf-8" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta name="google-site-verification" content="uuXuP1PlSlnJCf5mijFaZV0jEB6q6eGkWcBCX8cGs3M" />
      {if pages_keywords}<meta name="keywords" content="{pages_keywords}" />{/if}  
      {if pages_summary}<meta name="description" content="{pages_summary}" />{/if}
      {favicon}
    </head>

    {global_body_start}

    <body {if member_group=='1'}>
      <div id="layout">

    {global_page_header}

    <div id="header">
    
      {if member_group == '1'}
        <div id="admin_links">
            <a href="/admin.php" target="_blank" rel="noopener">Control Panel »</a>
            <a href="http://{path=">Entry summaries »</a>
            <a href="http://{path=logout}">Log Out »</a>
        </div> {!-- END #admin_links --}
      {/if}
    
      <h1 class="site_title">{site_name}</h1>
      
    </div> {!-- END #header --}

    And {favicon} is a global variable

    <link rel="shortcut icon" href="/favicon_frontend.ico" />
  • #6 / Jul 13, 2010 2:44am

    Craig Allen

    135 posts

    Sorry, forgot to mention that this is happening with EE v2.0.2pb01 for this. But I’m about to start updating to EE2.1, so will see if this solves it.

  • #7 / Jul 13, 2010 4:04am

    John Henry Donovan

    12339 posts

    Great stuff. Let us know know you get on

  • #8 / Jul 13, 2010 4:38am

    Craig Allen

    135 posts

    The update to EE2.1 went smoothly, but the snippet issue remains.

  • #9 / Jul 13, 2010 6:51pm

    Brandon Jones

    5500 posts

    Craig, is there any change if you remove the {favicon} global variable so that we’re only dealing with snippets? You might be running into a parse order issue.

  • #10 / Jul 13, 2010 7:00pm

    Lisa Wess

    20502 posts

    Hi, Craig - snippets are not intended to be nested inside one another.

  • #11 / Jul 14, 2010 2:35am

    eddyfever

    62 posts

    I have the same problem and i don’t have snippets nested.

    What i found out is when you edited a snippit you have to update it,
    and then go to the template and press there also update. Then it works.
    But this is not how it should be, and can be really frustrating when you edited something and then it doesnt work directly.

    I use EE 2.1.

    {menu_top_left}

    <div id="menu_top_left">
     <ul>
        <li><a href="#"><h2>Home</h2><p>tekst1</a></li><br />
            <li><a href="#">Page1</p><h2>tekst2</h2><p></a></li><br />
        <li><a href="#">tekst3</p><h2>Page2</h2><p></a></li><br />
        <li><a href="#" class="#"></p><h2>Page3</h2><p>tekst3/p></a></li><br />
     </ul><br />
    </div>

    ps. This also happends when i edit something with NavEE.

  • #12 / Jul 14, 2010 2:59am

    Craig Allen

    135 posts

    Thanks Lisa.

    I’ve moved my GLOBAL_START and GLOBAL_END code from being snippets to being templates.

    Even so, it’s odd that it works sometimes and not in others, and sometimes will not work, but then can be made to work if the snippet is recreated.

    You might consider putting a note in the documentation warning of the instability if embedded.

    Eddyfever; your suggestion make no difference in my case.

  • #13 / Jul 14, 2010 3:52am

    eddyfever

    62 posts

    Then i think we have a different problem :D

    And like Lisa said, snippits nested does not work.
    Did you try to make the sitename a global_variable?

  • #14 / Jul 14, 2010 3:58am

    Craig Allen

    135 posts

    {site_name} is a predifined EE global variable, not something I created.

    As I explained in my reply to Lisa, I have removed the nesting by using templates instead of my GLOBAL_START and GLOBAL_END snippets.

  • #15 / Jul 14, 2010 7:00am

    David S

    110 posts

    I have the same problem and i don’t have snippets nested.

    What i found out is when you edited a snippit you have to update it,
    and then go to the template and press there also update. Then it works.
    But this is not how it should be, and can be really frustrating when you edited something and then it doesnt work directly.

    I use EE 2.1.

    {menu_top_left}

    <div id="menu_top_left">
     <ul>
        <li><a href="#"><h2>Home</h2><p>tekst1</a></li><br />
            <li><a href="#">Page1</p><h2>tekst2</h2><p></a></li><br />
        <li><a href="#">tekst3</p><h2>Page2</h2><p></a></li><br />
        <li><a href="#" class="#"></p><h2>Page3</h2><p>tekst3/p></a></li><br />
     </ul><br />
    </div>


    ps. This also happends when i edit something with NavEE.

    I have the same problem. This workaround works though. but it is pretty annoying when you are editing the templates as files in a texteditor instead of going through the template-editor. I really hope you will find a solution to this one.

    /David

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

ExpressionEngine News!

#eecms, #events, #releases