![]() |
why is my html fragment floating to the top of the page? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: why is my html fragment floating to the top of the page? (/showthread.php?tid=53325) |
why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]bill19[/eluser] Hello everyone, I am working with codeigniter 2.1 and twitter bootstrap to develop a site. I used php's domdocument to generate some dynamic html which I want to insert into a page.Unfortunately , the php generated fragment is now the first thing on the page when I look at the html source: Code: <div><h2>Available Now:</h2></div> I actually want to insert this further down the page, after the hero-unit view as you can see in my controller code. my controller is as follows: Code: public function index() What am I doing wrong? Thanks, Bill why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]Matalina[/eluser] Are you echoing things in $this->currentItems? why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]bill19[/eluser] Yes, Here's the code that generates a portion of the created html: Code: $dom = new DOMDocument('1.0'); //Create new document with specified version number Its within currentItems() Thanks for looking at it, Bill why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]Matalina[/eluser] You can't echo in a controller. You have to load a view if you want it to display correctly with other views. why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]CroNiX[/eluser] CI uses buffering for the output of views. So, if you have an echo somewhere that isn't in a view, those echos will appear before the final output of the buffered views as it will output that first and then dump the contents of the buffer. why is my html fragment floating to the top of the page? - El Forum - 07-19-2012 [eluser]bill19[/eluser] Thanks for explaining that. I saved the output into an array and passed it into my view to echo out there. Best regards, Bill |