0

I wanted a Joomla extension which would (among other things) allow me to show a different image for every day of the month but couldn't find one.

So I decided to learn PHP to do the job. I wrote some code which works perfectly under WAMP as PHP using:

$handle = opendir(dirname(realpath(__FILE__)).$imagedir) or die ("cannot open directory");  

However when I use this in Metamod etc I get an opendir function error.

Please explain how I should reformat this for Joomla 3.

  • Often opendir errors spring from permission errors. Running on a local machine WAMP will have more access than running on a server. You might want to try echoing out the dir string that you're calculating to see if it points to the right place on the server, and then see what the permissions are for it. – Arlen Aug 14 at 19:21
1

A bit more code (what is behind $imagedir, what is the way of ouput) would help.

Just a shot in the blue:

$img = JPATH_SITE.'/images/someFolder/'.date('d',time()).'.jpg'; // absolute path

$img = __DIR__.'/someFolder'.date('d',time()).'.jpg'; // abs. path relative to current file

$imgContent = filet_get_contents($img);

As relative src url:

 $img = JURI::base().'images/someFolder/'.date('d',time()).'.jpg';
 // http://domain.com/images/someFolder/27.jpg
0

JFolder is used to get the contents of a directory within Joomla, presuming that is what you are trying to do with that line of code.

Methods here: https://docs.joomla.org/API17:JFolder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.