Welcome Guest, Not a member yet? Register   Sign In
Problem with partial views in svn CI 1.6.1
#1

[eluser]James Gifford[/eluser]
This problem exists only in the svn version of CI, not the official 1.6.1 release.

I like to use a partial view system with my projects where I load pieces of a page into a main view "skeleton" file. For example, the view file "post.php" might contain the HTML for one blog post and could be loaded several times with different data to display a full page of posts. This works fine so far as of CI 1.6.1, but a change made to the svn version breaks the technique.

According to the change log, on March 17th the function call on line 708 of Loader.php was changed from include to include_once. Among other things, this prevents partial view files with the same name from being loaded more than once per page.

I know there has been much discussion on this issue in the forums and I also realize my view organization technique is not officially supported in CI (I use a custom view library), but I'd like to report this as a potential bug regardless.

Maybe there is a way to allow the use of include for loading views and include_once for everything else?
#2

[eluser]Sam Dark[/eluser]
Have you filled bug report alreay?

I have the same problem. Here is the test case:

Code:
<?php
class Test extends Controller  {
    function index(){
        print $this->generateText('data1');
        print $this->generateText('data2');
    }
    
    private function generateText($data){
         return $this->load->view('test', array('data' => $data), true);
    }
}
?>

I'm using this to send 4-5 notification emails at one time. They are generated from templates and each uses its own data.
#3

[eluser]James Gifford[/eluser]
I haven't filed a bug report because this doesn't apply to an official release yet and also because the new functionality may be intentional. I just wanted to bring the issue to the attention of the developers in case they had overlooked how it would effect view files.

Also, I know a lot of people were pushing for the change to improve performance and reliability so I'm not sure what can be done to satisfy everybody. I just hope something can be done because I really don't want to change how I handle view files.
#4

[eluser]Sam Dark[/eluser]
You can report SVN version bug actually.

Well... let's wait for some official comments.
#5

[eluser]Derek Allard[/eluser]
It wasn't our intention to intentionally break anything. James/Sam, if you can track down the offending include_once() and save me some time, then I'll look at what we can do to get this fixed up. Thanks.
#6

[eluser]James Gifford[/eluser]
Hi Derek, I didn't mean to imply that you'd intentionally break any functionality, I just wasn't sure if this behavior was expected or not.

The include_once is on line 708 of Loader.php and I have verified that replacing it with include fixes the problem.

Thanks for looking into the issue.
#7

[eluser]Sam Dark[/eluser]
I have verified it also.
#8

[eluser]Derek Allard[/eluser]
My bad. I didn't mean to imply that you meant to imply that... :: group hug! ::

Wink

All fixed up, thanks for reporting both.
#9

[eluser]Nonox[/eluser]
Hi, I'm using CI 1.7.0, If a want to "jump" to another function I receive this msg:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 178708 bytes) in /opt/lampp/htdocs/system/libraries/Loader.php on line 708

Do you know how can I solve that?

Thanks
NB
#10

[eluser]Derek Allard[/eluser]
NB, google around for that error. It isn't a CI thing, there just some demanding code running.




Theme © iAndrew 2016 - Forum software by © MyBB