codeigniter helper function did not loaded - php

I try to "rebuild" again my web project in Codeigniter, but I totally forgot how to setting it..
In the last 3 years, this website contains no error and all works great. but when I try to reopen again, it contains errors like this :
Fatal error: Call to undefined function admin_info() in C:\xampp\htdocs\misnews\application\controllers\home.php on line 27
PS : the admin_info() functions are inside the helper, and I loaded it in autoload and added $this->load->helper('basic_helper); in the home controller
Can you help me?
Thanks

If your helper is named basic_helper.php
application / helpers / basic_helper.php
Then all you should need to do is $this->load->helper('basic');
You can also autoload helper in
application / config / autoload.php
When you need to use helper $this->basic->some_function();

Related

Showing header and footer in CodeIgniter custom error pages

In my CodeIgniter folder I have got custom error pages for each type of error in application/views/errors/html like error_404.php etc. So when I tried to update the layout and added <?php $this->load->view('header'); ?> on top then it started to show me errors like:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Exceptions::$load
Filename: html/error_404.php
So I want to know how can I make it to work? I also tried to extends the Exception class from CI_controller but still no luck. Please help me to add my custom header to my custom error page. Thanks.
PS: I want to clear that even if I use some how PHP's include() function but I also want to use base_url function for e.g.
<script src="<?php echo base_url('assets/js/iconmenu.js'); ?>" type="text/javascript"></script> <br>
One more thing I want to clear that I am using Codeigniter 3.0 which provides all error's templates but don't allow to use $this->load function.
I don't know the reason for the above error. Might be it's because of core libraries are not loaded in case error 404 is happened.
You can try another way. See application/route.php and there is an option to override the 404 url, $route['404_override'] = '';
Example: Create a method error_404 in Welcome controller and update the route variable like $route['404_override'] = 'welcome/error_404';, now you can use whole helpers / libraries etc.
See routes
Hope this will help!

Kohana 3.2 not working Form helper

I have some code, where is used Form helper. All worked well. Now I have error
Call to undefined method Form::open()
When I check SYSPATH exist classes Form and Kohana_Form
This situation is in each file where is used this helper.
This is kohana 3.2. In this files was not any changes. I tried it on PHP 5.4 and PHP 5.5
Any idea why? Thanks in advance for help.
The most likely thing is that you have a Form.php somewhere that's overriding the SYSTEM Form.php. To find out if this is happening, use the Kohana::find_file() function like this:
Kohana::find_file('classes', 'form');
The output from this should tell you the path of the Form.php that's being used when you call the Form class. Check if it's the one in the SYSTEM folder.

Controller::detect() undefined in Laravel 4

I am getting an error message when trying to register all the controller routes in Laravel 4 (Illuminate) by adding:
Route::controller(Controller::detect());
to my routes.php
The error :
Error: Call to undefined method Illuminate\Routing\Controllers\Controller::detect() in C:\wamp\www\travless\app\routes.php line 13
I suppose they changed the function name, but I don't know where to find it because it is still an alpha version and there is no documentation I'm aware of.
This function has been removed in Laravel 4 because of inconsistent behavior with varying filesystems. The proper way to register controllers should be to explicitly define each one you wish to use in your routes file.
You need to register each controller manualy in routes.php file
Route::controller('users', 'UsersController');
First params stands for URL to respond, second one is controller's class name

Multiple template in codeigniter

In one of my application I integrated a codeigniter template using HOOKS method... Its working pretty well ... The hooks/ template will call in Controllers Constructor ..
the 'default.php' is located in views folder ...
But I need 2 templates for my proj .. Can any one help me how to handle this ?
Please help
Look for the 'Themes' library... each theme has its own folder inside the views folder...and its called like this : 1st line is template 2nd line is the page
$this->themes->set_theme('theme');
$this->themes->set_template('template')
then in your controller its invoked using: $this->themes->view('view');
simple insert a {page_content} tag into your template where you want to insert the page code.
It may still be available on the CI wiki.

Zend Framework: How to register and call plugin in bootstrap file

1- How can I register and call my plugin in bootstrap file?
2- Is it a better way to use boostrap file intead of application.ini file for registering and calling my plugins ?
Note: Iam using custom path ('Mylib/Controller/Plugin') for storing my plugins.
Actually I want to convert following 'application.ini' entries
autoloaderNamespaces[] = "Mylib_"
resources.frontController.plugins.CheckHasAccess = "Mylib_Controller_Plugin_CheckHasAccess"
into bootstrap _initPlugin function.
Can some one guide me in this regards with some sample code.
Thanks in advance
1 - You would need first to load your plugin class (via Zend_Loader or require_once)
then create your plugin yourself:
$plugin = new MyPlugin();
then you can call any public method of your plugin you want and at the end you can register it within front controller:
Zend_Controller_Front::getInstance()->registerPlugin($plugin);
2 - if your plugins need to be somehow configured before they can be used by framework - then you can create and configure them yourself (as described above). If they don't need any special actions - then you can let them to be created by Framework automatically.

Categories