cssabc123 Posted September 30, 2015 Share Posted September 30, 2015 I created the repeated fields for the building repeated fields example of processwire. in _main.php I executed directlyforeach($page->buildings as $building) { echo "<h2>{$building->title}</h2><p>"; echo "Height: {$building->feet_high} feet, "; echo "Floors: {$building->num_floors}, "; echo "Year built: {$building->year_built} </p>";} This works without placeholder variables in _init.php, and hence no template placeholder population. Not sure how the can be in placeholders. So for the delayed output strategy it appears some output can/must not have placeholder variables? Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2015 Share Posted September 30, 2015 maybe you don't need to used delayed output? it can make many things more trouble than it's worth. Have you tried the simple include head/foot method. 2 Link to comment Share on other sites More sharing options...
cssabc123 Posted September 30, 2015 Author Share Posted September 30, 2015 What about for instances when one need delayed output for repeated fields? How do you code it? Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 30, 2015 Share Posted September 30, 2015 The delayed output is not much different from not using it. Instead of just echoing out content immediatelly (no matter if at once or in _header.php -> template.php -> footer.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <h1><?php echo $page->title; ?></h1> </body> </html> you're going to construct the "content" of the page before any html is outputted. // _init.php $content = ""; // template.php $content .= "<h1>$page->title</h1>"; // _main.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <?php echo $content; ?> </body> </html> The difference it that you're temp. storing the content (or whatever types you use/need) is stored in a variable until it's echod. The main benefits are that it does allow for later alteration of markup and sometimes cleaner code. Essentially just don't use echo in your template files, but only with the placeholder variables in _main.php and you've delayed output. 1 Link to comment Share on other sites More sharing options...
cssabc123 Posted September 30, 2015 Author Share Posted September 30, 2015 For PageArray in Delayed Output there will be two For loops, one in template.php and _main.php, if one really one to do delayed output? Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 30, 2015 Share Posted September 30, 2015 No. $content (as it's named in my example) will ever only be a string of markup. You'd build _main.php once and everything else happens in the template.php. You just part for part add markup to $content and in the end _main.php will just spit everything out what is in that variable. Link to comment Share on other sites More sharing options...
cssabc123 Posted September 30, 2015 Author Share Posted September 30, 2015 Yup, all html can be formed in template, not even needed to split anything in _main.php. Thanks LostKobrakai. Link to comment Share on other sites More sharing options...
cssabc123 Posted September 30, 2015 Author Share Posted September 30, 2015 (edited) <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> supposed to be in head tag before any css. That means in delayed output I have to put it in _main.php, however I need to use it in my template say basic-page.php. Is pure-min.css visible in the template? Edited September 30, 2015 by LostKobrakai Merged into the other delayed output topic Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 30, 2015 Share Posted September 30, 2015 Delayed output is just another way to generate the full html markup, that is send to the browser. The browser won't get anything different, therefore everything js/css is unaffected of this. 1 Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2015 Share Posted September 30, 2015 the only snafu i encounter with delayed output is that i lose the syntax highlighting of the HTML when it's all inside quotes as well as no double cursor (in ST for example)... though i do use it a lot when constructing repeating elements like table rows, lists, galleries.. also with delayed output you can store the markup into the wire cache. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 30, 2015 Share Posted September 30, 2015 You could in theory set sublime text up in a way that it does highlight html in quotes. 1 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