mo Posted December 10, 2009 Share Posted December 10, 2009 I am new to OOP but proficient in PHP. I am rewriting my website and I decided to use codeigniter as cakePHP was confusing as hell. My current site is all procedural and I have a php file called main_tmpl.php which contains various variables (listed below) that I use in all my pages for the HTML formatting. How can I reproduce this in codeigniter? I do not want to enter my core HTML in every view page. Example variables in my main_tmpl.php file and how I use them. $html_head = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"> <head>"; $html_head_end = "</head>"; $html_body_start = "<body>"; $html_body_end = "</body>"; $html_main_content = "<div id=\"main-frame\"><!--Main Frame Div:Start-->"; $html_main_content_end = "</div><!--Main Frame Div:End-->"; I echo these variables in my PHP pages. How can I reproduce this effect in codeignitor? Quote Link to comment https://forums.phpfreaks.com/topic/184582-html-templates-in-codeigniter-newbee/ Share on other sites More sharing options...
sKunKbad Posted December 13, 2009 Share Posted December 13, 2009 You just need to nest your views: $nested_view_data['title'] = 'Page Title'; $data['head'] = $this->load->view('head',$nested_view_data,TRUE); $this->load->view('main_tmpl',$data); This would assume you have a view named head, and there is a $title variable in it. This gets inserted into the main_tmpl view. Quote Link to comment https://forums.phpfreaks.com/topic/184582-html-templates-in-codeigniter-newbee/#findComment-976389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.