theoretic Posted August 14, 2020 Share Posted August 14, 2020 Hi guys and ladies! And thanks for Processwire! It appears i've found a very specific case of template rendering behaviour. The steps to reproduce this: Enable markup regions in site/config.php: $config->useMarkupRegions = true; Let's suppose we have a data file templates/data.php with the content like this: <? return ['name'=>'value']; ?> This file is included into a template file default.php in the following way: <? //getting data from external file $data = include 'data.php'; //the rest of template logic and output ?> <html> <?=$data['name']?> </html> In this case the pages with default.php template are being rendered in a very strange way (at least in fresh Firefox). A flash of unstyled content, followed by repaint and rendering of styled content. It's very likely that the "return - include" construction causes some output before all the page html is fully prepared. It's easy to "fix" this behaviour: <? //inisializing $data in-place $data = ['name'=>'value']; //the rest of template logic and output ?> <html> <?=$data['name']?> </html> I like that "include-return" code approach and use it in many of my projects, and it was always giving no problem with page rendering. With the markup regions turned on, it becomes a problem. Are there any ideas how to use both "include-return" and markup regions together with no rendering trouble? And what could cause that trouble? Thanks in advance! Link to comment Share on other sites More sharing options...
theoretic Posted August 14, 2020 Author Share Posted August 14, 2020 P.S. It appears that the problem exists in Firefox only. Vivaldi renders such pages nice and smooth. Link to comment Share on other sites More sharing options...
horst Posted August 15, 2020 Share Posted August 15, 2020 Maybe you can wrap a output buffer around it, (in a site/_main.php) ? ob_start(); // do all your template and include code // and finally flush it to the browser all at once: echo ob_get_clean(); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now