Welcome Guest, Not a member yet? Register   Sign In
Template Build Technicalities
#1

[eluser]domainsvault[/eluser]
Alright I am some what new to CI, I am attempting to build a custom template. Im pretty sure through my reading that the template phaser isn't exactly what I am looking for. So that said.

My current controller for default loads a single page where all the data ports through, that single file has multiple files included into it that make up the master template

header.php
footer.php
content.php

keep it sweet and simple for the sake of example. However I want this to be a some what universal concept with that whats the best way to handle a template like that, where essentially the content.php is the main file where the rest of the files would load in essence for the various sections of the site.

Is there a way I can modulize that idea or something? Reason I ask is I know when I go to
mydomain.com/something1 or mydomain.com/something2 its going to pull out what its gonna pull out and only way I can figure on that bit is include the template files the same way each time per controlers view file loaded, I think personally that may be redundant.

Any Ideas?
#2

[eluser]ηυмвєяσηє[/eluser]
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $data['main_content'] = "index";
        $this->load->view('includes/template', $data);
    }
    function home()
    {
        $data['main_content'] = "home";
        $this->load->view('includes/template', $data);
    }

}


"view/includes/template" dir includes
header.php
footer.php
template.php

template.php
Code:
<?php $this->load->view('includes/header'); ?>

<?php $this->load->view($main_content); ?>  
      
<?php $this->load->view('includes/footer'); ?>

this is one of the simple ways of templating..
#3

[eluser]domainsvault[/eluser]
function index()
function home()

being the equivilant url wise to

mydomain.com/index/
mydomain.com/home/

so If I am understanding that correctly basicly I want just one master controller for everything then run everything else out of modules on a per function basis for the need? am I correct in assuming that?

unless of course I need a custom controller to do something json or xml related or something else..
#4

[eluser]ηυмвєяσηє[/eluser]
links will be like
mydomain.com/site/index/
mydomain.com/site/home/


mydomain.com/controller/function/

you can make some modification to Url with routes.
http://ellislab.com/codeigniter/user-gui...uting.html


you can watch videos here to learn how ci works
http://net.tutsplus.com/sessions/codeign...m-scratch/
#5

[eluser]domainsvault[/eluser]
no way to do it without the concept of "/site/" being in the url? Or anything at all rather other than home or index, or whatever else I wanna add?
#6

[eluser]ηυмвєяσηє[/eluser]
as i said before u can do it with routes


if u use only one Controller
$route['(:any)'] = "site/$1";
mydomain.com/index/ will be like mydomain.com/index/site/





u can use one controller for each page.
for "domain.com/home"
Code:
class Home extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        // Your codes will be here
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB