So I thought I’d write my first codeigniter helper (still new to codeigniter somewhat). I needed something that would return an array of filenames from a photo directory to make hyperlinks to them. This was so I wouldn’t have to write out each filename myself, and adding new photos to the directory dynamically updated the site.
So I made a new helper called photo_helper.php which looks like this:
<?php
function spit_out_images($path)
{
$aryPhotos = get_filenames($path);
//does parsing to create hyperlinks
return $aryPhotos;
}
I set the file and photo helper to autoload inside my autoload.php
Then in my view I called the helper function spit_out_images like so:
<?php
$photoPath = base_url().'assets/_images/TwentyYears/thumbs';
echo spit_out_images($photoPath);
?>
But I never get any results out. I even tried echoing out the $photoPath variable to make sure it was giving out the path correctly, which it was.
I’m sure it is something simple I’m missing, I just can’t figure it out.
Thank you!
Make sure
base_url() . 'assets/_images/TwentyYears/thumbs'has the correct permissions for Apache/PHP to execute and read the directory and files,0755should be an appropriate mode.