php - CodeIgniter - Where to place scripts with -
i'm not sure if right place, since seem able answer anything, i'll give try...
i trying convert website, use codeigniter framework, , going okay believe. followed tutorial , made controller, can show basic pages. however, place php scripts (like 1 logging in) in separate folder, have following:
- /application/
- /views/
- /pages/
- /scripts/
- / templates/
the pages subfolder 1 containing normal sites, whereas scripts folder contains scripts (sorry weird layout, using lists). tried modify controller pages, work on scripts, looks this:
<?php class scripts extends ci_controller { public function run($page = 'home') { if ( ! file_exists(apppath.'/views/scripts/'.$page.'.php')) { // whoops, don't have page that! show_404(); } // connect database, using configuration /application/config/database.php $this->load->database(); // capitalize first letter $data['title'] = ucfirst($page); // wrap header , footer around content, define layout $this->load->view('templates/header', $data); $this->load->view('scripts/'.$page, $data); $this->load->view('templates/footer', $data); } } ?>
and try call script in file, located in /application/views/scripts/, called createnewproject.php, following url: "/index.php/scripts/run/createnewproject"
. however, in return 404-error. doing wrong, , using practice, in regards script placements?
perhaps apppath gives url trailing "/", try
if ( ! file_exists(apppath.'views/scripts/'.$page.'.php')) { // whoops, don't have page that! show_404(); }
instead!
Comments
Post a Comment