I try to start Flexigrid into Codeigniter.
I download demo files from here http://gembelzillonmendonk.wordpress.com/2010/06/28/flexigrid-and-codeigniter-with-advanced-searching-with-example/
but i wrong to set up something:
Instruction from site:
extract .rar to CI folder**
open your controller (ie: CI_Folder\system\application\controllers\flexigrid.php)**
configure flexigrid helper, and customize variable $colModel, example:**
code example
What I did:
I installed correctly CodeIgniter (copy and paste inside htdocs - xampp)
I created a database called 'country' and import sql file inside demo.
I copied correctly files an folders from demo files to my CI folder (called grocery-crud-demo).
But when I type on firefox http://localhost/grocery-crud-demo/index.php/flexigrid/index I have this error
Fatal error: Class 'Controller' not found in C:\xampp\htdocs\grocery-crud-demo\application\controllers\flexigrid.php on line 2
A PHP Error was encountered
Severity: Error
Message: Class 'Controller' not found
Filename: controllers/flexigrid.php
Line Number: 2
Backtrace:
I read instruction also from here: http://roadmyapps.toile-libre.org/index.php/flexigrid/examplebut I don't understand which code exactly I must have into flexigrid.php
I don't understand how configure flexigrid helper, and customize variable $colModel.
I need exact code into files. Have you idea?
I find CodeIgniter 1.7.3 -- I repeat steps -- new error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Ajax_model::$db
Filename: models/ajax_model.php
Line Number: 34
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\grocery-crud-demo\system\application\models\ajax_model.php on line 34
Code of ajax_model.php is this: http://pastebin.com/P3KawC7S
Probably you are using newer version of CI than one on tutorial.
As I can see tutorial is written for 1.7.2 version.
Try to change
class Someclass extends Controller
{
public function someclass()
{
}
public function index()
{
//etc, etc
}
}
with
class Someclass extends Controller
{
public function __construct()
{
parent::__construct()
{
}
}
public function index()
{
//etc, etc
}
}
Also, for models too. Like
public function Ajax_model()
{
parent::Model();
$this->CI =& get_instance();
}
should be
public function __construct()
{
parent::__construct();
$this->CI =& get_instance();
}
Try that way.
Spot those differences. Those should change in every controller and model respectivelly. Follow this link for upgrading your app.
If fail again, see the CodeIgniter documentation about upgrading versions.
Related
I am newbee for Amfphp+codeignitor, I am unable to see the answer for the question amfphp 2.2, index.php gives fatal error?, Or it is not clear to me.
I followed the process mentioned here
http://www.nunomira.com/blog/2012/03/codeigniter-2-0-3-with-amfphp-2-0/
I am getting the same error - Fatal error: Cannot use object of type stdClass as array in D:\vhosts\site\application\libraries\Amfphp\Plugins\AmfphpMonitor\AmfphpMonitor.php on line 167
No Idea where i am doing the mistake.
http://localdomain.com/index.php/amf/gateway is the url i am trying.
How to rectify? what is the problem? if the problem is resolved, will i look service browser?
Experts please guide me on this...
Here is the code
Folder Structure
-controllers
-amf
-services
-Testservice.php
-Gateway.php
-libraries
-Amfphp (Amfphp folder)
Gateway.php
<?php
require_once APPPATH . "/libraries/Amfphp/ClassLoader.php";
class Gateway extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$config = new Amfphp_Core_Config();//do something with config object here
$config->serviceFolders = array(dirname(__FILE__) . "/services/");
$gateway = Amfphp_Core_HttpRequestGatewayFactory::createGateway($config);
$gateway->service();
$gateway->output();
}
}
Testservice.php
<?php
class Testservice extends CI_Controller {
public function getMessage()
{
return array("param1" => "param1");
}
}
Thanks
someone pointed out a similar problem and a fix has been made but not released yet. Could you try replacing your AmfphpMonitor.php code with this one?
https://github.com/silexlabs/amfphp-2.0/blob/master/Amfphp/Plugins/AmfphpMonitor/AmfphpMonitor.php
Hi I am new to CodeIgniter and am taking a tutorial. I ran into an error
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: subview
Filename: admin/_layout_modal.php
Line Number: 7
An Error Was Encountered
Unable to load the requested file: .php
I followed the tutorial to the tee and I cant seem to find out where I am going wrong.
here is the controller
<?php
class User extends Admin_Controller {
public function __construct() {
parent::__construct();
}
public function login() {
$this->data['subview'] = 'admin/user/login';
$this->load->view('admin/_layout_modal', $this->data);
}
}
and the view
<?php $this->load->view($subview); ?>
Please help...
If you gave script from your .php file not tutorial then everything is ok.
You are probably typing the wrong url in when you try to access the page. Make sure you are loading "admin/user/login" instead of "admin/dashboard/modal".
If you are following tutplus tutorial- building cms with codeigniter, First watch two episodes, Managing User Part 1 and Managing User Part 2 and then Start building, Your question will be answered on Part 2.... the dashboard has to declare the subview variable and
CREATE THAT admin/dashboard/index.php file in views
class Dashboard extends Admin_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
$this->data['subview'] = 'admin/dashboard/index';
$this->load->view('admin/_layout_main',$this->data);
}
public function Modal(){
$this->load->view('admin/_layout_modal',$this->data);
}
}
don't need to pass data to $this. Just pass the data to
$data['variable_name']=data;
pass this $data variable to view through load class.
I know this has been asked before, and I've looked through every answer posted, but to no avail. Basically, I am trying to extend the Codeigniter form validation library on a CI2+ project, but every single time I get the error:
Fatal error: Call to a member function get_errors_array() on a non-object
Below is my code:
application/core/CB_Form_validation.php
class CB_Form_validation extends CI_Form_validation{
function __construct($rules = array()) {
parent::__construct($rules);
log_message('debug', "CB_Form_validaiton class initialized");
}
public function get_errors_array() {
return $this->_error_array;
}
}
and then in my ajax file I have the construct etc.
public function save(){
if($this->form_validation->run() == FALSE){
}
}
and inside that if statement I have tried the following:
echo $this->form_validation->get_errors_array();
echo $this->cb_form_validation->get_errors_array();
echo get_errors_array();
I have also tried placing the CB_Form_validation.php in application/libraries as well. Just as well, I have also tried this in my construct of my ajax controller
$this->load->library('CB_Form_validation');
$this->load->library('core/CB_Form_validation');
And I have set CB_ as my custom class prefix
Turns out that to fix this, you should do the following:
Move your custom form validation class to the application/libraries folder
You can keep the construct of your custom class how it is
Use $this->form_validation->method() to access the function you would like
As long as your loading the form_validation library, you don't need to perform $this->load->library('custom_class') because CI picks up on your custom prefix anyways
Hope this helps someone
I've came across something that drives me crazy. please help me :(
I'm try to extend the CI_Loader Core in-order to create global header and footer.
For some reason, the extending causes error.
The extend code:
class MY_Loader extends CI_Loader
{
function __construct()
{
// i need the codeigniter super-object
// in all the functions
$CI =& get_instance();
}
public function load_header()
{
echo 'header';
}
public function load_footer()
{
echo 'footer';
}
}
The error i currently get
Unable to load the requested file: helpers/url_helper.php
UPDATE: CHANGED THE CODE - NEW ERROR
class MY_Loader extends CI_Loader
{
function __construct() {
parent::__construct();
$CI =& get_instance();
$CI->load = $this;
}
public function load_header()
{
echo 'header';
}
public function load_footer()
{
echo 'footer';
}
}
now i get some error with the header
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /mounted-storage/home75b/sub007/sc43190-SREL/gogetmilk.com/application/core/MY_Loader.php:1)
Filename: libraries/Session.php
Line Number: 672
UPDATE #2
I'm not its the right way to fix it. but its working.
line 672 in libraries/Session.php sets a cookie
i've added a test to see if headers were already sent:
if (! headers_sent() )
{
setcookie(
$this->sess_cookie_name,
$cookie_data,
$expire,
$this->cookie_path,
$this->cookie_domain,
$this->cookie_secure
);
}
its not working ok.
i've created session before printing anything, after printing, within views, after loading views, etc..
does anyone believe this will cause any problems?
problem solved and was not related to codeigniter. see answer at the bottom.
The error i currently get Unable to load the requested file:
helpers/url_helper.php
You're getting this error because you didn't load URL helper. I don't see any call to any URL helper function so I assume the error is being thrown in another file ... Try adding
$this->load->helper('url');
in relevant file or just load it in the config/autoload.php
and, yes, use parent::__construct(); as answered by Broncha
Your construct should call the parent's construct
function __construct()
{
parent::__construct();
// i need the codeigniter super-object
// in all the functions
$CI =& get_instance();
}
Problem solved. it wasn't even a CodeIgniter Issue.
It was an invisble BOM at the begining of the file.
Used this application to remove this bytes: http://sourceforge.net/projects/bomremover/
Thanks everybody for your help :)
<?php
class Blog extends CI_Controller {
function Blog() {
parent::CI_Controller();
}
}
I'm trying to create a constructor in Code Igniter for my class 'Blog' and the above code is giving me a fatal error:
Fatal error: Call to undefined method
CI_Controller::CI_Controller() in
C:\xampp\htdocs\mysites\blog\application\controllers\blog.php
on line 5
How do I fix this?
(I'm going through a online video tutorial on the official code igniter website but I think the tutorial is about 2 years out of date as some of the things are not working when I follow them exactly as shown in the video, this being one of them - the link to the video is here - I encounter this problem towards the end of the tutorial about 8 minutes in)
It should be this...
<?php
class Blog extends CI_Controller {
function __construct() {
parent::__construct();
}
}
The tutorial you are probably going through is based on 1.7.2 which had a core of php4 which did not use the php5 __construct() method of building Class constructors. Codeigniter 2.0.0 has a php5 core and uses it.