Welcome Guest, Not a member yet? Register   Sign In
Gaps at top of code
#1

[eluser]Mobious[/eluser]
Hi All,

Hope you can help.

We have made a custom CMS based purely on CI but for some bizarre reason we are getting blank lines at the top of our code above the doctype etc. It does not affect the code in any way its just very annoying. We have a separate header and footer with the content in between and have not gaps at the top of any code it seems to be something to do with the standard CI code but we can't find anything in the libs or anywhere else that would cause this to happen.

If anyone has any ideas about why this is happening, feel free to suggest.

Cheers.
#2

[eluser]Andrew Cairns[/eluser]
Hi Mobious,

Could you post a sample controller which is giving this problem?
#3

[eluser]Mobious[/eluser]
Hi Andrew,

All of the controllers that we have created are doing the same problem but I will post an overview of a controller

Code:
class test extends Controller
{
    function test()
    {
        parent::Controller();

        // load models, libs, helpers, etc
    }

    function index
    {
        // General processing

        $data = array('header' => 'test');

        $content = array('content' => 'Hello World');

        $this->parser->parse('header.tpl.htm', $data);
        $this->parser->parse('template.tpl.htm', $content);
        $this->load->('footer.tpl.htm');
    }
}

That is the jist of it (obviously with more code) but all of the above processing goes into the two arrays to be parsed.

Hope you you can help.
#4

[eluser]Andrew Cairns[/eluser]
If there is no space within your header.tpl.htm file, then this should be fine.
I would be tempted to check your vhost and .htaccess file to make sure there is no auto_prepend_file setup.
#5

[eluser]Mobious[/eluser]
Thanks for the suggestion but I have looked at the .htaccess and index.php files and can't see anything in there and I don't auto_prepend set anywhere. Its clearly something to do with the code and not the underlying CI code because I have had a look at other CI sites and no spaces appear there.

If you or anyone else has any other suggestions, it would be much appreciated.
#6

[eluser]Andrew Cairns[/eluser]
can you post the contents of your header.tpl.htm file ?
#7

[eluser]Mobious[/eluser]
Here is the top part of the header.tpl.htm

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;

From there is goes into more meta tags and css links. There are no spaces above the doctype so I cant understand how the gap is happening.
#8

[eluser]Andrew Cairns[/eluser]
I cant see anything that could be causing any spacing.
Try using a die() statement after parent::Controller() and view the source to see if there is still spaces.
This will narrow down when the spacing is occurring.
#9

[eluser]Mobious[/eluser]
I tried using the following without success:

Code:
class test extends Controller
{
    function test()
    {
        parent::Controller();

        echo 'test';
        die();
    }

    function index()
    {
        ............
    }
}

This still produced a blank line above the echo which ha made me think its something in the underlying CI code. No amends have been made to the CI code that would make this happen, the only code to be modified in the pagination code, but this was occurring before the mod was done. I have checked the routes and config files and nothing wrong in those.
#10

[eluser]Johan André[/eluser]
Are you using closing php-tags in your files?
If you do - remove them.
This can cause the problem you describe and more, like getting blank pages and stuff...




Theme © iAndrew 2016 - Forum software by © MyBB