• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sharing a template accross whole project & css folder location

#1
[eluser]DumpProgrammer[/eluser]
Hi I am new to MVC so these might be a silly questions.

1) I have a template for my website which I would like to share accross my site. In php I was using an php inlude header, footer, sidebar etc. Now in codeigniter I am not sure if I have to create view files for header,footer and side bar etc.

2) Where is it best to store the CSS files,javacsript, jquery , htaccess and image file etc for a project because I had made an include file located in the system folder for my CSS but when I click on my link it takes me back to http://Ci/index.php/home so the CSS does not work any more and I have to remove the index.php. When I go to my config file and put a blank value (I m not sure where exactly because I am not on my computer but this is where you set the base url.).

Thanks in advance

#2
[eluser]whobutsb[/eluser]
[quote author="DumpProgrammer" date="1262893367"]Hi I am new to MVC so these might be a silly questions.

1) I have a template for my website which I would like to share accross my site. In php I was using an php inlude header, footer, sidebar etc. Now in codeigniter I am not sure if I have to create view files for header,footer and side bar etc.

2) Where is it best to store the CSS files,javacsript, jquery , htaccess and image file etc for a project because I had made an include file located in the system folder for my CSS but when I click on my link it takes me back to http://Ci/index.php/home so the CSS does not work any more and I have to remove the index.php. When I go to my config file and put a blank value (I m not sure where exactly because I am not on my computer but this is where you set the base url.).

Thanks in advance[/quote]


I have been using the Assets Library with great success, for managing my CSS, Images, and JS files. And I usually store my .htaccess at the root of application as well.

For templating there are lots of solutions, there is no right way to do it I have found. My pattern is to create a template file called "template", and place it in to View folder. In there I have my HTML declarations, load CSS, JS, files and create the navigation that will be used site wide. For the space where the content is going to go I add:
Code:
$this->load->view($view)

In my controller I call the template and add the view:
Code:
function index(){
    
    $data['view'] = 'home_page_view';
    
    $this->load->view('template', $data);  
}

So now I can create a file in View folder called "home_page_view.php" and can write in all the content for the home page view.

#3
[eluser]Ben Edmunds[/eluser]
I always recommend the MY_Controller method of templating.

It's simple yet completely effective.

#4
[eluser]whobutsb[/eluser]
Can you give a quick example of your solution? I"m always interested in seeing alternative approaches.

#5
[eluser]n0xie[/eluser]
Take a look @ jedd's how to on the wiki

#6
[eluser]DumpProgrammer[/eluser]
Thanks guys I will try bith examples because I am still playing around with codeigniter.

#7
[eluser]Ben Edmunds[/eluser]
You can also check out my github for a full site example. It's basically the same as jedds implemented into a working sample site.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.