I'm trying to set up Codeigniter in my mac, but with no luck. When loading every page, appears a blank page.
I'm following the Codeigniter tutorial from the official site.
Checked the base URL configured in config.php, but seems to be ok, now: http://localhost:8080/
Also, the directory where there is the file that I'm trying to open seems to be in the correct folder: nfs://192.168.64.2/opt/lampp/htdocs/application/views/pages
The pages.php code is the next:
<?php
class Pages extends CI_Controller {
public function view($page = 'home')
{
}
}
I expected to load about.php and appear the header, about page and footer.
to load the view in codeigniter, you need to add below line of code in your controller function.
$this->load->view($page);
note: I am assuming that you have all the view pages are located at the route of application/views/ folder.
When you download Codeigniter and is extracted, generate a "Codeigniter xxx" folder with files. Is necessary to copy this folder to htdocs folder and rename with the name that you want for your project.
If you copy the files instead the folder inside htdocs, could produce this problem.
Related
I'm trying to push a Laravel project to production on Hostgator.
I followed this tutorial. Only the last step, changing one line on paths.php I couldn't accomplish because this file do not exists anymore on Laravel: http://shincoding.com/laravel/installing-configuring-laravel-shared-hosting/
I put all my project files on root/quasenerd_base/quase-nerd, except the content of the public folder, which I moved to root/public_html.
I successfully change the path on index.php to the quasenerd_base folder:
require __DIR__.'/../../quasenerd_base/quase-nerd/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../quasenerd_base/quase-nerd/bootstrap/app.php';
When I access the url http://quasenerd.com.br, I can see my main layout. But it won't load the #section of the page.
In addition, any other url that I try to access returns a 404 page not found. (for example, /login). Apparently I can't access any of my views.
I tryed to add to my index.php:
$app->bind('path.public', function() {
return __DIR__;
});
but it didn't work.
Any ideas?
I have one project on shared hosting and I use this tutorial: YouTube
I hope it will help you.
I have changed the name of codeigniter and placed htdocs then in application folder I have created a new folder in that new folder again I created some folders for different web pages in each and every folder I added controllers,models,view files. Now I want to access a controller file which is in the new folder.
I tried with default route but not working..Can anyone suggest
Create as many folders as you want inside the controller model and view folders in CodeIgniter and not outside them if you really want to organise them.
Remember to set base URL in application/config/config.php file and default router inside the application/config/routes.php file.
If you have problems please comment below describing errors.
I am creating a module called "Web" in magento 1.7.2. Folder structure is like app/code/local/Company/Web/ then Block, controllers, Model, etc, Helper. Again under controllers creating Adminhtml folder and IndexController.php file. Under Adminhtml folder ProductController.php file is there. I have another one file which is in my root folder called reader.php file. I want to include that file in my ProductController.php file. But unable to do so. I have tried by the following code:
$basePath = Mage::getRoot();
include($basePath.'/reader.php');
Please help me how to include the file.
Thanks in advance.
Mage::getRoot() gives you the app folder. You should use Mage::getBaseDir() instead. That will give you your absolute base dir.
I was loading view in CodeIgniter as
$this->load->view('../../myfolder/footer');
It was working fine on windows machine. I have uploaded app to linux machine and start getting error
Unable to load the requested file: ../../myfolder/header.php
myfolder is in CI application folder.
How can i load view from application/myfolder
Please help me and thank you in advance.
Why you need tho load views in application/myfolder?? Code Igniter expects that views are located in application/views or application/views/myfolder. Put your files in application/views and then you can load it using:
this->load->view('footer');
or
this->load->view('myfolder/footer');
If it worked on Windows but no longer works on Unix, it could be because the filepaths are case sensitive in Unix.
Check the file structure and file names to make sure they match the CodeIgniter requests exactly.
E.g.:
$this->load->view('../../myfolder/footer');
Will fail trying to load:
../../MyFolder/footer
../../myfolder/Footer
../../MyFolder/Footer
etc
$this->load->view(base_url().'myfolder/footer');
That should work but I have no idea why you're trying to work outside the views folder to begin with. Just structure your views folder like below. Load the header, footer and anything else that's static from a template page.
Views
--pages
--admin
--templates
--etc.
I have developed the CRM based web application what i need to do is to integrate the wordpres with my CI first i have the problem when i include the main WP file
require('./wp-blog-header.php');
in my one of the CI view file the error i was getting that function site_url() conflicts this function is the base function of both WP and CI ,although i found a solution to include the WP file in the main index.php file of CI but there is uncertainity too that after this the session library of CI stops working is.
How to show the posts of WP in the footer of my CRM?
When using include or require in my CodeIgniter views I make sure the files I am linking to are outside of the CodeIgniter application folder as I had trouble using files there because of some permission problems. My solution was to just keep a folder in my web directory. You also cannot use base_url or site_url CodeIgniter functions here since you want to get the server path not the web address of the file. So you can use the php variable $_SERVER['DOCUMENT_ROOT'] which will return the root of your web directory.
It might look something like this:
require($_SERVER['DOCUMENT_ROOT'].'wp-blog-header.php');
Which would work if wp-blog-header.php was in your web root directory.