Thread

Problems with a rendering template

January 20, 2017 3:38am

Subscribe [1]
  • #1 / Jan 20, 2017 3:38am

    iameric

    44 posts

    Greetings - I hope I am in the correct subsection for this… not sure where it belongs.

    EE 3.5 on local dev, MacOS Sierra Server with MySQL - live site uploads to Nexcess

    Working locally on a upgrade from EE2 to EE3 for a client all has gone rather smoothly. This website has about 200 pages and they all use the very same layout file that contains the head and footer areas. From there each page then calls in it’s unique content.

    But after upgrading from EE2 to EE3, I began observing odd behavior with a particular page - the blog/index page. In this case the blog/index page is literally a copy/paste of the blog/article page and blog/index automatically loads the latest article. (the blog/article page is set to dynamic=”yes” where the blog index is not). A literal copy/paste other than this one single value.

    However I was unable to get the page to render at all. Article pages render perfectly fine but the index would not - it seems to fail rather silently on Opera and Safari with the message “Can’t open the page” or something of the like - Firefox says “Content Encoding Error - The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.”

    Once I disabled gzip compression it loaded, but not without a bit or weirdness. Remembering that this template is a copy/paste of another working template…

    Now the character “0” appears in the top left of the page - looking at the source shows “0<!doctype html>…” Even if I cut out all of the content and just leave the layout code in place I still get this “0” - I can not find this behavior on any other page as of yet.

    So as you can imagine - any suggestions welcome. I have the config file setup to show errors to logged in admins, but I see nothing when loading the page - I am dumbstruck.

    An of course this page is also live on the web in EE2 and working perfectly (www.medmal1.com/blog).

  • #2 / Jan 21, 2017 2:20pm

    Jeremy S.'s avatar

    Jeremy S.

    324 posts

    Can you post the template code?

  • #3 / Jan 25, 2017 7:05am

    iameric

    44 posts

    I hope this is the right way to post this - thank you, Jeremy, for your help - here is the code of the blog/index template:

    {layout="layouts/layout-main"
     bodyClass="blog"
    }
       <div id="article">
        {exp:channel:entries
         channel="blog"
         limit="1"
         disable="member_data|pagination|category_fields"
         status="Open|Featured"
         dynamic="no"
        }
    
        {if no_results}
        {redirect="404"}
        {/if}
        
        {layout:set name="title" value="{title}"}
    
        <a href="http://{blog_article_link}%22class=%22main_article" class="main_article" target="_blank">Original Article</a>{/if}
           </span>
           <ul class="share">
            <li>{lv_social_share_fb}</li>
            <li>{lv_social_share_tw}</li>
           </ul>
         </header>
    
         {if blog_article_image}
         <div itemprop="image">{blog_article_image}</div>
         {/if}
    
         {if blog_article_video}
         <div itemprop="video">
          <video id="article_video" src="{blog_article_video}" width="583" preload controls poster="{blog_video_poster}">
           It looks like your browser does not support mp4 formatted HTML5 video. :-(
          </video>
         </div>
         {/if}
         <div itemprop="articleBody">
          {if blog_article_rich}
          {blog_article_rich}
          {if:elseif blog_article_code}
          {blog_article_code}
          {/if}
    
          {if blog_footnotes}
          <div class="article_footnotes">
           {blog_footnotes}
          </div>
          {/if}
         </div>
    
         {if blog_embedded_js}
         {blog_embedded_js}
         {/if}
    
        </article>
        {/exp:channel:entries}
       </div>
       <div id="aside">
        <a>
         {exp:low_variables:single
          var="lv_blog_shorts"
          preparse:hasOffset="0"
         }
        </aside>
       </div>
  • #4 / Jan 25, 2017 7:11am

    iameric

    44 posts

    I tried to edit the post, looks like some of the code got chewed up and spit out incorrectly, but I am getting an error because of the low variables tag in the code section.

  • #5 / Jan 26, 2017 3:19am

    iameric

    44 posts

    Okay, so I have narrowed this down further… the code above, 1st line, refers to the layouts_main layout. In that layout file I made reference to two low variable files in the head. One of them is called lv-headmeta and the other is lv-social. The first adds a meta description depending on the url segment (among a few other things) and the latter adds social media stuff, Facebook og code and Twitter card info, again depending on the url segment.

    When I open these two files and remove code that looks like {if segment_1 == "blog"}…{/if} then the entire page works as expected. But if I add any of the logic back into either file I get the problem again with a 0 showing up in the top left corner of both the rendered page and the code when viewed (it appears before <doctype>).

    I have a feeling that this may not happen when the page is actually live as the exact same code is running in production right now - the only difference is that live is using EE 2.x and local dev is EE 3.5.

  • #6 / Jan 26, 2017 3:26am

    iameric

    44 posts

    Again I tried to edit the post receiving an error -“Something has gone wrong and this URL cannot be processed at this time.” - okay, well I wanted, and forgot, to add the code that appears in these two files… maybe someone can catch a problem with them that I am not seeing??

    From lv-headmeta:

    {exp:channel:entries
     limit="1"
     disable='member_data|pagination'
    }
    
    {if segment_1 == "blog" && !segment_2}
     <meta name="description" content="This is the Blog Description">
    {/if}
    
    {if segment_1 == "blog" && segment_2 == "article"}
     <meta name="description" content="{if blog_article_excerpt}{blog_article_excerpt}{if:else}{exp:chopper chars='140'}{if blog_article_rich}{blog_article_rich}{if:else}{blog_article_code}{/if}{/exp:chopper}{/if}">
    {/if}
    {/exp:channel:entries}

    and from lv-social:

    {exp:channel:entries
     limit="1"
     disable="member_data|pagination"
    }
    {if segment_1 == "blog"}
    <!-- Blog or News Post -->
    <meta property="og:description" content="{if blog_article_excerpt}{blog_article_excerpt}{if:else}{exp:chopper chars='140'}{if blog_article_rich}{blog_article_rich}{if:else}{blog_article_code}{/if}{/exp:chopper}{/if}" />
    <meta property="fb:app_id" content="666946003440426" />
    {/if}
    <!--- THEN ADDED LATER AFTER SOME OTHER CODE -->
    {if segment_1 == "blog"}
    <!-- Blog or News Post -->
    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:site" content="@888medmal1" />
    <meta name="twitter:creator" content="@888medmal1" />
    <meta name="twitter:title" content="{if layout:title != ''}{layout:title}{if:else}{title}{/if}" />
    <meta name="twitter:description" content="{if blog_article_excerpt}{blog_article_excerpt}{if:else}{exp:chopper chars='140'}{if blog_article_rich}{blog_article_rich}{if:else}{blog_article_code}{/if}{/exp:chopper}{/if}" />
    {if article_image}
    <!--
    Images for Twitter summary card: should be 120x120 and 120x90.
    Images for Twitter summary w/ Lg Image should be 280x150.
    -->
    <meta name="twitter:image" content="{article_image}" />
    {if:else}
    <meta name="twitter:image" content="/assets/i/tw_share_generic.jpg" />
    {/if}
    {/if}
    {/exp:channel:entries}

    Fingers crossed that it doesn’t come out as messy as it looks here in the edit window!!

  • #7 / Jan 30, 2017 7:30am

    Rob (bluedreamer)'s avatar

    Rob (bluedreamer)

    2792 posts

    I can’t see anything obvious but to narrow things down try starting with a simple template like:

    {exp:channel:entries channel="blog" limit="1" disable="member_data|pagination|category_fields" status="Open|Featured" dynamic="no"}
    <h1>{title}</h1>
    {/exp:channel:entries}

    Then start adding in template parts until it breaks, then you’ll know which bit is causing the error.

ExpressionEngine News

#eecms, #events, #releases