php not finding folder
I am converting a static site to C5, so am in the process of building a custom theme. So far it is all working well, with the following exception:
One of my html pages (now a .php page) has a chunk of php code in it. This php scans a folder and pulls in any image files in the folder and places them into my custom photo gallery. This all works fine on my local machine running WAMP (but I don't have C5 installed locally). However, on my host in C5 the php produces a warning
"opendir(/conc/themes/3mg/images/photos/) [function.opendir]: failed to open dir: No such file or directory".
However, that path shown does exist and has my images in it.
BTW, the variable set for the path is done as follows:
$images_dir = $this->getThemePath() . '/images/photos/';
I should note also that throughout my other files or in other html elements within this file, references to folders using "<?=$this->getThemePath()?>/some_folder/some_file" works fine.
One other question: Is it OK in C5 to run php code within the html/php file, or should the php code be placed in a single page file (now sure how to attempt this)? I would prefer to leave it as is for now if it can work.
Any thoughts would be greatly appreciated.
What might be easier is to use some of the things C5 is great with. File Sets
Upload whatever images you want into the file manager and then put them into a file set
on the page where you want those images to show, create a slideshow or gallery, there are a few that come free with C5, however, there are also some great add ons in the marketplace for some beautiful slideshows/galleries.
All of these add ons have an option to display all images within a file set.
Here is some documentation on file sets:
As for the gallery, I really need to use my own, as the client requires the photos be displayed in a very specific manner and with specific placement, etc. That part is a no-brainer, I just need to figure out how to get my gallery to see the photos (in a folder or in the file manager).
Based upon your response, I will indeed investigate file sets to see how I might employ them.
Thanks for your reply.
$images_dir = $this->getThemePath('images/photos/');
I'm wondering if the leading "/" is proper for what is being returned in these paths. I guess that would still be considered relative to the root dir.
I'm seriously doubting that your hosting provider has /conc/ as the DOCUMENT ROOT (it's possible, but unlikely).
If you are calling opendir() from a file in your theme directory you probably want something like opendir('3mg/images/photos/');
If that directory exists then it might be a permissions problem.
Yes, my php file in question here is in the themes directory. C5 is installed under public_html/, so the full path to that photos directory is: public_html/conc/themes/3mg/images/photos/. And yes, it really does exist.
I've tried various combinations of path formats, but can't get opendir() to see it.
<?php echo $this->getThemePath(); ?> returns "/conc/themes/3mg/"
opendir() takes either a fully qualified path (starting with /) or relative to the current directory.
So you probably want this:
If it tells you the directory does not exist, it's probably doesn't :)
So when I use:
as the path, now opendir() works. Note that simply using 'images/photos/' does NOT work. I should think it would.
However, that full path that opendir() likes is a problem, as when the <ul> gallery list is built, the urls such as:
are seen in a browser as:
Obviously you don't want the "home/edgwebde/public_html/" part seen from the browser.
Bottom line is that I'd like to use a relative path to my photo folder, but can't seem to get such a path to work.
Thanks so much to all of you for your patience with me. And sorry for the somewhat long convoluted post. I'll keep playing around with this...
BTW, feel free to check out the code at:http://www.edgwebdesigns.com/conc/index.php/photos/...
Note that this site is currently just a wireframe representation of what will eventually exist. For now everything there is just "placeholder" crap.
$images_dir - opendir('themes/3mg/images/photos/');
Sorry for the delay in replying, been off the 'net...