开发者

codeigniter template assistance

Hello all im new to codeigniter and new to the hole template system. så i hope some one will help me out and maybe look at my code and see if i can do something better so i can learn something new :).

i have try to install this template system williamsconcepts.com/ci/codeigniter/libraries/template/index.html

but i just cant get it to work, so i found this template system maestric.com/doc/php/codeigniter_template

but i dont know how to add a sidebar and footer function to it.

and i have try for 3 days now and just dont kno开发者_如何学Cw what to do :/. You can not see my project any longer here https://github.com/SimonJ/Hip-hop-project

Best Regards Sjmon


Your question should be asked on Stackoverflow.com - but I'll answer it for you anyway as I know when questions are moved so too are comments and answers.

I haven't used the abvoe two mentioned template libraries, but if you try Phil Sturgeon's template library you might find it easier: http://philsturgeon.co.uk/code/codeigniter-template

Sidebars and footers would be view partials. Basically a view partial is a view stored in a variable. You technically don't need a templating system to do this as you can simple go:

$data['header']  = $thos=>load->view('header', '', TRUE); // Returns a view as data
$data['sidebar'] = $this->load->view('sidebar', '', TRUE); // Returns a view as data
$data['footer']  = $this->load->view('footer', '', TRUE); // Returns a view as data

$this->load->view('content', $data);

Then in your content view file which in this case is called content.php located in your application/views directory you could go:

<?php echo $header; ?>
<?php echo $sidebar; ?>
<?php echo $footer; ?>

I however do recommend Phil's library as it is a lot nicer than storing views in variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜