Question

I know this question has probably been asked a hundred times, but I'm trying to call a helper I made up from autoload.php. I stored the helper file in shared_addons/helper. I called it new_helpers. The helpers file is:

<?php defined('BASEPATH') OR exit('No direct script access allowed.');

public function get_date($timestamp, $format) {
  list($date,$time) = explode("|", date("m/d/y|g:i A", $timestamp));
  $date = date($format, $date);
  return $date;
}
public function get_time($timestamp, $format) {
  list($date,$time) = explode("|", date("m/d/y|g:i A", $timestamp));
  $time = date($format, $time);
  return $time;
}

and in system/cms/config/autoload.php, I put:

$autoload['helper'] = array('new_helper');

However, I am still getting the error:

An Error Was Encountered [ 500 ]

Unable to load the requested file: helpers/new_helper.php

What am I doing wrong?

Was it helpful?

Solution

The helper file name should follow the template NAME_helper.php If you want to name your helper "pdf", for example, the file name would be pdf_helper.php.

You would then use the name WITHOUT the _helper suffix for loading/autoload. So $autoload['helper'] = 'pdf'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top