Welcome Guest, Not a member yet? Register   Sign In
how to simultate a template with codeigniter
#1

[eluser]Unknown[/eluser]
Hello,
sorry my english is very bad because i am frenchspoken but this framework interest me very much i understood architecture but i want to load all my views in one file like a template or a pseudo-frame i look help please !
thanks
#2

[eluser]Iksander[/eluser]
Controller:

Code:
class Your_Controller extends Controller
{
    function index()
    {
        $this->load->view('template');
    }
}
Template View:

Code:
$this->load->view('header');
$this->load->view('body');
$this->load->view('footer);
Header view:

Code:
<html>
<head>
  <title>My embedded view test</title>
</head>
<body>
  <h1>This is my header heading</h1>
Body view:

Code:
<p>All the main content stuff would go in this view</p>
Footer view:

Code:
<p>Maybe some footer stuff down here, like copyright and what not</p>
&lt;/body&gt;
</hml>


Hope that helps... there is a good tutorial around here somewhere if what I post is not enough. Just do a search for "views within views".
#3

[eluser]esra[/eluser]
If you want to use PHP exclusively without using a template system language, you might want to take a look at Coolfactor's View library. It's a good solution for mangaging master views (effectively, PHP-based templates) and view fragments (partials or blocks), and embedding CSS, JS and meta data code.

There are forum treads and wiki articles about using full template parsing engines with CodeIgniter. You might try doing some forum searches for Smarty, bTemplate, YATS, TemplateFlexy, Tiny-But-Strong, etc. CI also plays well with some Javascript libraries with their own layout features such as YUI (Yahoo User Interface components), EXT (Jack Slocum's extensions to YUI (with adapter support for AJAX libraries), MooTools, JQuery (user contributed plugins), etc. CI comes with a light Template Parser library which could be used for smaller projects.

You will achieve faster application performance by sticking with PHP as a template language. The decrease in application performance when using a full template engine will vary depending on the complexity of the engine and caching support. The Javascript layout libraries result in larger drains in application performance initially but this can be improved significantly with PHP caching techniques and the use of selectors.




Theme © iAndrew 2016 - Forum software by © MyBB