CodeIgniter Forums
Hook generates whitespace - 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: Hook generates whitespace (/showthread.php?tid=8852)



Hook generates whitespace - El Forum - 06-03-2008

[eluser]dioony[/eluser]
Hi there!

I have a problem with my hook. If the hook is enabled, the hook creates a whitespace at the beginning of each page. Normally this is not a problem... But with RSS there is a problem, because XML (thus rss) expects the xml-expression at the first character...

Normally the output should generate "<?xml version=...".
If hooks are enabled it generates " <?xml version=...".

My Hook:
Code:
class TitleHook
{

    function doTitleHook()
    {
        $CI =& get_instance();
        $output = $CI->output->get_output();                    
        
        if(isset($CI->main_title)){
            $title = "WildeWetten - ".$CI->main_title;            
        }else{
            $title = "Normal Title";
        }
        $output = str_replace("{{MAIN_TITLE}}",$title, $output);
        
        $CI->output->_display($output);
        
    }
}

in hooks-config:

Code:
$hook['display_override'][] = array('class'    => 'TitleHook',
                                    'function' => 'doTitleHook',
                                    'filename' => 'TitleHook.php',
                                    'filepath' => 'hooks'
                                   );

i also tested something like
Code:
$output = substr($output,1)
, but it seems, that the whitespace will be added after the hook...

Does anybody know how to fix?