Welcome Guest, Not a member yet? Register   Sign In
multiple views per controller
#41

[eluser]mrahman[/eluser]
Allow me Derek Jones. I said the same as mikeni earlier in this topic and no one replied me. Correct me if i'm wrong.

mikeni, I came here from ASP.NET. not even Java like you. As MS highly recommends developers to use the 3-tier approch for data,business logic, and display layers, i used to follow that approch only after spending more than a year of writing everything in a single file or two. nothing was preventing me, that was encouraging, because a beginner can't follow best practices all time.

About your questions about how people template their pages with CI at an enterprise level, and, if it possible to “extend” or “inherit” templates...
I think they are the same question. and yes you can inherit or extend. for now the way most people follow is to save views as fragments, a set of fragments, or both. that's all I need for instance. not an object oriented approch you're right, I think it will be a cool feature in the next version of this open source framework, and there's a topic in this forum that states making Views as a library.
#42

[eluser]mikeni1225[/eluser]
thanks for the reply, i guess what i need to do is keep researching and examining what others are doing for best practices. i'm hoping to find an enterprise level code igniter example. I wish CI would make a video tutorial of one.

im sorry, im a little new to php frameworks, could you give an example of what you mean by fragments?

thanks again,

mike





[quote author="mrahman" date="1201435490"]Allow me Derek Jones. I said the same as mikeni earlier in this topic and no one replied me. Correct me if i'm wrong.

mikeni, I came here from ASP.NET. not even Java like you. As MS highly recommends developers to use the 3-tier approch for data,business logic, and display layers, i used to follow that approch only after spending more than a year of writing everything in a single file or two. nothing was preventing me, that was encouraging, because a beginner can't follow best practices all time.

About your questions about how people template their pages with CI at an enterprise level, and, if it possible to “extend” or “inherit” templates...
I think they are the same question. and yes you can inherit or extend. for now the way most people follow is to save views as fragments, a set of fragments, or both. that's all I need for instance. not an object oriented approch you're right, I think it will be a cool feature in the next version of this open source framework, and there's a topic in this forum that states making Views as a library.[/quote]
#43

[eluser]E1M2[/eluser]
Was looking into various approaches a few months ago, here is my list of references.
Best practice for common dynamically generated partials?
Automatic Layout Inclusion
Expression Engine Template Parser
Extending Controller
View Library


Take a look into Matchbox (previously Modular Separation) -- a modular approach to building a large application.
Modules and partials
Modular Separation - deprecated but worth the read
Matchbox 0.9.2


Search terms for further research:
HMVC
Partials
Fragments
Blocks
Base controller


Get familiar with the wiki
wiki.codeigniter.com
#44

[eluser]mrahman[/eluser]
[quote author="mikeni1225" date="1201484731"]
im sorry, im a little new to php frameworks, could you give an example of what you mean by fragments?
[/quote]

you gave a good example. see each of your parts:

[quote author="mikeni1225" date="1201413693"]
banner
leftside_menu
rightside_blah
content_A
content_B
footer
[/quote]
we can create a view for each. call each a 'fragment', since it's not a complete html page by itself. Now, since views can contain other views, create a view that holds views from(banner~content_B), {content}, and footer. finally, fill this {content} with content_C, content_D or both. this is not a tutorial, check the video tutorials
#45

[eluser]CI MikeD[/eluser]
[quote author="Derek Jones" date="1201306334"]Right, we'll discuss this internally and update the requirements to reflect that decision once 1.6 is released.[/quote]

any news on this? I also updated to 1.6 only to find out it is not working as we have MySQL - 4.0.24 on our server.

Is there any manula fix to instal 1.6 on MySQL - 4.0.24? Is it even advisable? What to do in our situation? Thank for reply.
#46

[eluser]Derek Jones[/eluser]
Sorry about that MikeD - I'll update the docs in moment, but yes, CI will require MySQL 4.1+ starting with version 1.6 to work with MySQL. I would personally recommend that you upgrade MySQL. MySQL 4.0 has not been supported by MySQL since 2006, and this year it will even stop receiving security fixes. MySQL doesn't even have versions prior to 4.1 available for download any longer, and the benefits you would gain are very real. If for some reason you cannot do so, you can modify the MySQL driver's db_set_charset() method to just return TRUE, and everything else should continue to work.
#47

[eluser]Ignacio[/eluser]
Really thanks for this feature.
#48

[eluser]bijon[/eluser]
Quote:Michael Wales
Posted: 18 January 2008 04:06 PM

/application/libraries/MY_Controller.php
class Public_Controller {
function Public_Controller() {
parent::Controller();
register_shutdown_function(array(&$this, "shutdown"));
$this->load->view('header');
}

// Ghetto destructor for PHP4 support
function shutdown() {
$this->load->view('footer');
}
}

/application/controllers/whatever.php
class Whatever extends Public_Controller {

function index() {
$this->data->test = 'This is a test.';
$this->load->view('home', $this->data);
}

}

This is very interesting technique .i want to set template which includes:
- header
- menu
- content
- footer
I do not want to call the header,menu,footer in each controller .Header,Menu,footer is fixed always .I just change the content Data. Actually I want to do just create a thing like ASP.net Master page . well i donot test the code below but is the techique work ?
Quote:class Master_Page {

function Master_Page() {
parent::Controller();
$this->load->view('header');
$this->load->view('menu');
$this->load->view('footer');
}


}


Quote:/application/controllers/whatever.php
class Whatever extends Master_Page {

function index() {
$this->data->test = 'This will diplay in the Contet .';
$this->load->view('content', $this->data);
}

}


Thanks
Bijon
www.saidur.wordpress.com
#49

[eluser]Craig A Rodway[/eluser]
@bijon: One answer to your question is farily simple, and one that a lot of people dismiss or overlook in favour of obscure template libraries or splitting the core template up into headers/footers (which can lead to missed or unclosed or inconsistent tags).

Consider this:

/application/controllers/whatever.php

Code:
class Whatever extends Controller {

  function index() {
    $data['test'] = 'This will diplay in the Contet .';
    $this->load->view('content', $data);
  }

}

/application/views/content.php

Code:
<html>
<head>
<title>My CI Site</title>
</head>
<body>
<?php $this->load->view('header'); ?>

  <div id="menu">
    &lt;?php $this->load->view('menu'); ?&gt;
  </div>

  <div id="content">
    &lt;?php echo $test; ?&gt;
  </div>

&lt;?php $this->load->view('footer'); ?&gt;

&lt;/body&gt;
&lt;/html&gt;

The following files are loaded from the main content page to provide additional content:

/application/views/header.php
/application/views/menu.php
/application/views/footer.php
#50

[eluser]Unknown[/eluser]
I upgraded to CI 1.6 this morning and I can't get the multiple view loading to work. What happens is the last view in the chain is the only one displayed. I am using Matchbox as well. Has anyone run into any problems with Matchbox on 1.6 ?




Theme © iAndrew 2016 - Forum software by © MyBB