Welcome Guest, Not a member yet? Register   Sign In
HMVC and Layout = problems
#1

[eluser]groyk[/eluser]
Hi Guys

I have a BIG problem with all my pages generated with CI.

I use HMVC and a layout class


In ALL my pages I get either -- or --- as the first charters in all pages witch is really annoying. I believe this is why my app can't run at my production server! See error message below
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/e-smith/files/ibays/ipcam/html/ci_1.7.2/codeigniter/CodeIgniter.php:1)

Filename: libraries/Session.php

Line Number: 662

Here is the first 2 lines of one of my pages

Code:
--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

I don't know if it can be an encoding problem, but it seems like I have the same problem with both my development server and my production server!

Layout class:
Code:
&lt;?php  
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Layout
{
    
    var $obj;
    var $layout;
    
    function Layout($layout = "layout_main")
    {
        $this->obj =& get_instance();
        $this->layout = $layout;
    }

    function setLayout($layout)
    {
      $this->layout = $layout;
    }
    
    function view($view, $data=null, $return=false)
    {    
        $loadedData = array();
        $loadedData['content_for_layout'] = $this->obj->load->view($view,$data,true);
        
        if($return)
        {
            $output = $this->obj->load->view($this->layout, $loadedData, true);
            return $output;
        }
        else
        {
            $this->obj->load->view($this->layout, $loadedData, false);
        }
    }
}
?&gt;

Hoping that someone can help me out!
#2

[eluser]tomcode[/eluser]
Guess it's a whitespace problem. Take out the closing PHP tags, check on white spaces before opening tags.
#3

[eluser]groyk[/eluser]
[quote author="tomcode" date="1264391605"]Guess it's a whitespace problem. Take out the closing PHP tags, check on white spaces before opening tags.[/quote]

Hi tomcode

Thank´s for your advice, i will try that. About the closing PHP tags, should they be removed in all files. If not. witch files?
#4

[eluser]tomcode[/eluser]
You don't need them but they don't bother ... as long as You don't have a white space after them.
#5

[eluser]groyk[/eluser]
Hi tomcode

I've now removed ALL php closing tags from my project. It has removed almost all the weird charters. But still I have a few I just can't get rid off!!

Is there other things to check?
#6

[eluser]tomcode[/eluser]
1. You need to check whether You have white spaces / line feeds BEFORE PHP opening tags at the beginning of files

2. Remember: everything outside an opening PHP tag will be sent to the browser

3. You mention now weird chars
Quote:... It has removed almost all the weird charters ...

What do You mean by that ?
#7

[eluser]groyk[/eluser]
Hi

Attached picture shows one of the places where the problem appears!

The code that generates this output is shown below.

Master View (from Layout library)
Code:
<div id="sidebar">&lt;?=modules::run('base/main_menu')?&gt;</div>

Controller base/main_menu
Code:
function main_menu()
    {
        $this->load->model('s_auth');
        $this->lang->load('main_menu');
            
        # Auth Menu
        $links = array(
        array('/auth/users', 'View Users'),
        array('/auth/create_user', 'New User'),
        array('/auth/roles', 'View Roles'),
        array('/auth/create_role', 'New Role')        
        );
        
        #$att = array('class' => 'submenu');    
        # END
        
        $data['menu'] ='<div class="sidebar_head">'.$this->lang->line('main_menu_users').'</div>';
        $data['menu'] .= $this->s_auth->menu($links);
        
        $this->load->view('orange/main_menu',$data);
        
    }

Sub View for main_menu
Code:
&lt;?=@$menu?&gt;
#8

[eluser]tomcode[/eluser]
Maybe this file (main_menu.php) is UTF-8 encoded with BOM, some browsers can't deal with that.
#9

[eluser]groyk[/eluser]
Tried to encode all files to UTF-8 without BOM. But It still don't change anything!!

Is there a way to encode a dir including all subdirs?

I am Using WAMP on a winbox. Maybe the problem is there anywhere OR?
#10

[eluser]groyk[/eluser]
Hmm. I just can't figure it out.

Here is a link to my app. I someone want to see the problems!

www.smartkant.dk/ci_erp.zip

User: admin Pass: admin
User: test Pass: test

Remark this link is only for a pre pre alpha release!




Theme © iAndrew 2016 - Forum software by © MyBB