Page 1 of 1
my html fragment is floating to the top of my page!
Posted: Tue Jul 17, 2012 10:50 pm
by kc11
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: Select all
<div><h2>Available Now:</h2></div>
mod: 1mod: 2<div class="row"><div class="span6"><h2>13 mole st</h2><p>Fugazi</p><p><a class="btn" href="http://localhost/bootstrap1/index.php/template_controller/1">Learn More »</a></p></div><div class="span6"><h2>11 mole st</h2><p>Fugazi</p><p><a class="btn" href="http://localhost/bootstrap1/index.php/template_controller/2">Learn More »</a></p></div></div>
---------generated fragment is above
<!DOCTYPE html>
<html lang="en"><head>
I actually want to insert this further down the page. What am I doing wrong?
Thanks,
KC
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 5:46 am
by social_experiment
What is above the doctype declaration on the page where you created the code
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 7:52 am
by kc11
Here is the code:
Code: Select all
$dom = new DOMDocument('1.0'); //Create new document with specified version number
$div= $dom->createElement('div') ;
$dom->appendChild($div);
$h3=$dom->createElement('h2','Available Now:');
$div->appendChild($h3);
echo $dom->saveHTML();
So, if I understand correctly, this means we are using xml version="1.0".
Thank you for looking at it,
Bill
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 8:01 am
by social_experiment
If you comment the above line, does the content disappear?
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 8:12 am
by kc11
Yes,
Please note that I have another section of code (which I did not include above) that produces a second fragment of html which is included in the original html fragment I showed in my first post. it also starts with:
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 8:32 am
by social_experiment
Code: Select all
<?php
$dom = new DOMDocument('1.0'); //Create new document with specified version number
$div= $dom->createElement('div') ;
$dom->appendChild($div);
$h3=$dom->createElement('h2','Available Now:');
$div->appendChild($h3);
echo $dom->saveHTML();
?>
Is there a specific reason why you have this above the doctype declaration
Re: my html fragment is floating to the top of my page!
Posted: Wed Jul 18, 2012 8:57 am
by kc11
Its not above the doctype declaration, I want the area of generated HTML to be lower.
To build this page my codeigniter controller looks like:
Code: Select all
public function index()
{
$this->load->view('header'); // static HTML including doctype declaration
$this->load->view('navbar'); // static HTML
$this->load->view('hero_unit'); // static HTML
$this->currentItems(); // my generated HTML ( which we are discussing )
$this->load->view('footer'); // static HTML
}
Re: my html fragment is floating to the top of my page!
Posted: Thu Jul 19, 2012 4:44 am
by social_experiment
Ok; well my knowledge of both DOMDocument and codeIgniter are non-existant so an alternative i can offer is to refer you to a tutorial on the codeIgniter site; Hth
http://codeigniter.com/user_guide/tutor ... pages.html
Re: my html fragment is floating to the top of my page!
Posted: Thu Jul 19, 2012 8:11 am
by kc11
Thanks for looking at it,
KC