Welcome Guest, Not a member yet? Register   Sign In
Strange problem with $this->load->view
#1

[eluser]Dionysius[/eluser]
Hi to all!
Here my routes.php:
Code:
$route['articles/:num'] = "articles/index";
$route['articles/:num/:num'] = "articles/index";

$route['files/:num'] = "files/index";
$route['files/:num/:num'] = "files/index";

Here is my test site based on CI 1.5.4: http://z-nsk.ru/ci/

URL http://z-nsk.ru/ci/files/3 works good. It loads controller "files" which gets data from DB.
But http://z-nsk.ru/ci/articles/<number&gt; doesn't work correctly - it redirects to home page. I have found that all code in "articles" controller works correctly till string
Code:
$this->load->view('articles', $data);
It redirects browser O_o
If I changes it to
Code:
echo "blah-blah";
$this->load->view('articles', $data);
it says
Quote:blah-blah
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/z-nsk.ru/httpdocs/ci/system/application/controllers/articles.php:64)

Filename: helpers/url_helper.php

Line Number: 455
I can't understand WHY? If I changes this piece of code to
Code:
$this->load->_ci_load(array('view' => 'articles', 'vars' => $this->load->_ci_object_to_array($data), 'return' => false));
it works good!

Can somebody explain this mysticism?

And else: URL http://z-nsk.ru/ci/articles/view/<number&gt; doesn't work anyway.

And all of these problems didn't appear at localhost.

Info:
Server: CentOS, Apache 2.0.52, PHP 4.3.9
Localhost: Windows XP, Apache 1.3.33, PHP 5.1.6
#2

[eluser]Dionysius[/eluser]
Well, I just have changed PHP on localhost to 4.4.2 from 5.1.6 and these troubles appeared.
Now I know, that this is a problem of PHP 4.
#3

[eluser]Dionysius[/eluser]
If I change code of view() method to
Code:
echo "blah-blah";
//return $this->_ci_load(array('view' => $view, 'vars' => $this->_ci_object_to_array($vars), 'return' => $return));
it redirects to home page anyway. I can't understand why redirect() method is called.
#4

[eluser]xwero[/eluser]
I'm guessing it has to do with the code in the view file where you use a url helper method. As you can see the error is generated from that file.
#5

[eluser]Dionysius[/eluser]
But there are not redirect() calls in the view file articles.php. And I can change "articles" in $this->load->view() to "footer". footer.php has pure HTML. But result will be the same: redirecting to home page. Sad
#6

[eluser]Dionysius[/eluser]
ups...
#7

[eluser]Michael Wales[/eluser]
Then it has to do something with your routing or are you using caching?
#8

[eluser]Dionysius[/eluser]
No, I don't use caching.
#9

[eluser]Michael Wales[/eluser]
Paste your routing.
#10

[eluser]Dionysius[/eluser]
[quote author="walesmd" date="1196294103"]Paste your routing.[/quote]
It is in my first post.
.htaccess
Quote:RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]




Theme © iAndrew 2016 - Forum software by © MyBB