We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Problems with a rendering template

News and General

iameric's avatar
iameric
48 posts
8 years ago
iameric's avatar iameric

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).

       
Jeremy S.'s avatar
Jeremy S.
353 posts
8 years ago
Jeremy S.'s avatar Jeremy S.

Can you post the template code?

       
iameric's avatar
iameric
48 posts
8 years ago
iameric's avatar iameric

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" rel="noopener">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>
       
iameric's avatar
iameric
48 posts
8 years ago
iameric's avatar iameric

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.

       
iameric's avatar
iameric
48 posts
8 years ago
iameric's avatar iameric

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.

       
iameric's avatar
iameric
48 posts
8 years ago
iameric's avatar iameric

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!!

       
Rob Allen's avatar
Rob Allen
2,950 posts
8 years ago
Rob Allen's avatar Rob Allen

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.