BEST Way to Integrate eSPG into Wordpress
There are a few sites out there with instructions on integrating Enhanced Simple PHP Gallery into Wordpress. The method I am going to describe, however, is the best. One key feature of this method that sets it apart is that it makes use of the TITLE tag. Another feature is that when you change the theme of Wordpress, it will change in your eSPG installation as well. It also makes use of the add_filter function in Wordpress to dynamically add the necessary code to the HTML HEAD. Here’s how it’s done:
Make a backup of header.php in your eSPG installation directory. Then, replace its contents with the contents of this file.
Then, make a backup of footer.php. Replace the contents of footer.php with the contents of this file:
You will need to edit sp_styles.css to match your theme. If you do not want to include the sidebar, there are a few more steps involved. If you are interested, leave a comment on here and I will add the steps to this post. Also leave a comment if there are any questions; I will probably end up opening a forum thread for this. As always, please let me know if you use this!
July 6th, 2005 at 10:22 pm
are you saying to follow the installation instructions on quirm.net for espg 1.7…but not to follow quirm’s ‘integrating into Wordpress’?
July 6th, 2005 at 10:48 pm
Jay,
Yes, exactly … You shouldn’t need to download the WordPress files on quirm.net at all. Just replace the contents of header.php and footer.php with the files linked above. I should update this post to cover more ground… Thanks so much for commenting!
July 7th, 2005 at 12:53 pm
when editing the sp_styles.css , what? is the proper way to code the import url(/wp-content/themes/themefolder/theme-I’m-using.css
July 7th, 2005 at 1:31 pm
You actually shouldn’t have to worry about that… With this method, because get_header() is called, it will use the standard header of your theme. All of the tags that are normally in the <head> of your blog will be there, including the call to the CSS file.
July 7th, 2005 at 6:08 pm
http://griffinsmithy.com/photoalbum/ is what I’ve got on my site so far. Several extra links show up in the pages and I haven’t figured out how to turn the sidebar off yet.
What I’m trying to accomplish is making the photoalbum show up inside of my Page named Photos which you can see at http://griffinsmithy.com
I’ve been doing searches all day on the WP forums trying to figure out how or if SPG or eSPG can be integrated into the content of a Page (note, the capital ‘P’–not terribly good choice of label for the WordPress function, and it plays havoc in finding good search results.)
I’ve looked at all the other image plugins out there and SPG/eSPG are the best fit for my wants–but it’s sure taking a lot of tweaking. Part of that might be the fault of my using the Semiologic theme Strawberry creme version.
another issue I’ve encountered is the tendency of something in the SPG/eSPG script that tends to make directories and thumbnails with an owner of ‘nobody’ instead of my actual account. More specifically, the cache/rcache contents are created that way. After a previous install, I learned to make the folders and chmod them first so the owner permissions would be me, but the script creates the thumbnails in such a way that I haven’t been able to refresh or delete them.
Don’t suppose you’ve encountered solutions to these problems Dan?
July 7th, 2005 at 8:24 pm
Alrighty … here’s how you turn of the sidebar … first, at the bottom of header.php … change class=”narrowcolumn” to class=”widecolumn” … then, remove the line in footer.php that says <?php get_sidebar(); ?>
Now, about putting the gallery into a content page in Wordpress… I’m going to bet that if it’s possible, it will be so much of a headache that finding a different route will be more productive…. It will also be easier to manage. eSPG also has the admin pages, so even if it were possible to integrate it into a static content page, getting to the admin pages would pose a problem.
The way I’ve done it on this site is by hard-coding the links into the WP template header. I’ve taken out the function in the sidebar template that displays the list of pages because if I kept it, I would have duplicates (the about page and links page would be duplicates because they are WP static pages, but the rest would not be because they are put together outside of WP, and one is an email link).
Where did those other links come from in your photoalbum page? The projects, solutions, downloads, etc… Are they going to be used? They had to have come from somewhere
… That’s odd ..
I’ll download that template that you are using if I can find it and check the source so I can be of more help …
July 7th, 2005 at 8:44 pm
And about the FTP problems… I have actually run into this before … The conclusion that I came to is that the problem is related to whether PHP is in CGI mode or Apache module mode. Luckily, my hosting provider allows me to change it via a web interface, so it is now in CGI mode and works fine. In my case, the files were owned by “dhapache” in module mode because PHP scripts were running under that name. When I logged into FTP using my own username, I couldn’t delete them. In CGI mode, the PHP scripts are run under my username, and I can now delete them. Your hosting provider may not give you the option of CGI mode… I hope they do, but they may or may not. If you have to be in module mode, however, there must be a way around this problem.. Your best bet for this particular situation might be a call or email to your hosting provider’s support team. They can delete the files for you, without the need for a script to do it.
July 7th, 2005 at 9:04 pm
It looks like the Semilogic plugin may be the culprit for the extra links … that appears to be the case .. i’m looking at the Semilogic theme homepage, and some of those same links are there. I don’t have any experience with Semilogic, but from what I’m reading it looks like there are a bunch of WP plugins that come with it. Perhaps one of those plugins will control the links. It may even be possible, using this Semilogic CMS, to create a link that goes right to your photo gallery!
July 8th, 2005 at 5:33 pm
Yes, the extra links in the Semiologic theme come from the config.php file. I’ve commented out the extra ones I don’t want displayed. The reason they didn’t all show on my main page is because of the way the theme is being called by WP. The theme works as a plugin via WP whereas eSPG is using the theme files more directly. I’m still trying to figure out which script, plugin, and theme files have the desired effects–but you’ve been very helpful so far.
I do have certification in web development in PHP, but it still takes a while to figure out undocumented code. You taught me about CGI/Apache factor, and that may be a possibility here. My host has helped me with files that get ‘chowned’ to ‘nobody’. I’ve taken a look at Dreamhost though now (due to your mention on a forum) and I’m tempted to switch
July 8th, 2005 at 5:58 pm
One thing I noticed about the Semilogic CMS is that the sidebar table cell is hard-coded into footer.php, so it won’t be possible to remove the space on the right … that might not be a show-stopper, though … In the eSPG footer.php, just remove that line that says <? get_sidebar() ?> so at least the sidebar code won’t be right below your gallery. So the extra links are commented out of config.php right now? Could there possibly be another config.php somewhere (i.e. in the photoalbum folder), one where they are not commented out? That’s the only explaination that I can think of as to why those links could be showing up in the gallery page.. I mean, when they are commented, the script couldn’t possible use them!
You could use that config file to your advantage, though… Add a line that says $sem_header_nav[’Photos’] = ‘/photoalbum’; (adding that “/” to those links would be a good idea) and then you won’t have to worry about integrating the gallery into a WordPress “static” content page. And on top of that, the URL will be nice and clean.
I always recommend Dreamhost to everyone that asks; Their service is impeccable. Making the switch certainly wouldn’t be a bad idea, as long as there isn’t some sort of contract with your current provider… They even have a neat referral program, so please don’t forget me
.. They are constantly upping disk space and bandwidth allocation, which is nice.
Within the next couple of days I plan to make a post about how to check to see if a server is running PHP in module mode or CGI mode. Did your host delete the files for you, or were they able to fix it so that it would not be a problem anymore?
July 19th, 2005 at 6:34 pm
Hey Dan, I’ve got my “bested groovenectar-style” gallery working now. I decided to hold off using the Semiologic theme since it is a bit more complicated than I want to tackle right now. I’m using Azeem Azeez’s White as Milk theme in the meantime to simplify things. It also happens to work very nicely with eSPG with minimal modification to the styles.css.
Haven’t got everything “just so” yet, but my goal was to get a nicely functioning site up and start blogging the stuff I want to get online.
For anyone out there setting up their cache/rcache folders, I suggest you manually create those two directories first and chmod them 775 rather than letting the script create them. The script sets the owner as “nobody”, but creating the directories ahead of time so the script doesn’t have to will keep them set to your real owner permissions. (and thus be able to delete the cache/rcache if necessary.
Since the script already created them, I was able to rename them to something different, then create properly owned folders with the original cache/rcache name and permissions.
To summarize my process for a new install…
download only the eSPG files from quirm.net, you don’t need the Wordpress integrated files, nore that webpage of instructions
Install eSPG per Quirm’s Readme
Come to this page “best way to integrate” and use Dan’s header and footer files to modify your eSPG installation
modify both your eSPG and currently active Wordpress themes
July 19th, 2005 at 7:33 pm
I’ve noticed an address directory forming problem on my site. I’ve tried to search the Skyzyx forums but I get too many hits that aren’t relevant. Perhaps you know the file I need to modify to get this link
http://griffinsmithy.com/photos/sp_index.php?dir=./Turkey
to show the main directory name instead of the code?
July 20th, 2005 at 1:27 am
Very nice! It looks great!
Try this to get the directories to display instead of the “?dir=” variable…
In sp_config.php, look for the “//$modrewrite Settings” section and turn the $modrewrite variable to true. See if that works right away. It ought to, and if it doesn’t it could mean that the hosting provider doesn’t support custom .htaccess files. The .htaccess file is actually what makes it happen. It comes in the zip file, and should be located in the root directory of the gallery (you may have to configure your FTP software to show hidden files in order to see it, though). The .htaccess file shouldn’t need to be modified, only sp_config.php. If it doesn’t work right away, change the $modrewrite back to false. Most likely the host isn’t going to allow it to work, but a search on the Skyzyx forum for htaccess might shed some more light on the situation. I hope it works with no trouble!
Good idea creating the cache/rcache folders before the script does! I added your link to the sidebar on here, by the way
July 20th, 2005 at 6:00 pm
Setting $modrewrite to true worked…now I get a cleaner looking URI
I’m looking forward to the release of either Paul Griffin’s SPG2 or the image posting features that apparently seem scheduled for WP 1.6
September 26th, 2005 at 12:31 pm
hi I integrate eSPG with Wordpress and I have one problem
my site: http://www.promanski.info has menu on the right
but in gallery menu is below photos…how fix this?
thanks for answers
September 26th, 2005 at 4:27 pm
Fascik, I’m looking into this now… It seems as if it is going to be rather complicated.
September 26th, 2005 at 4:46 pm
Alright, I found the problem. The #main DIV is wrapping the photo gallery and the sidebar, when it should only be wrapping the gallery. I would have to see your PHP source in order to get to the bottom of this myself. I added some </div>’s after the gallery and the page rendered as it should.
September 27th, 2005 at 12:27 am
Dan You’re great, I add 2 <div>’s to footer.php and it fix all
Thanks for files (for integrate gallery) and help
Only what I should do is make the same CSS style in gallery and my page.
October 15th, 2005 at 3:30 am
Hello Dan. Your code for the heather is the solution for me to integrate eSG. But when clicking on a directory-thumbnail I get the following errors :
Warning: readdir(): supplied argument is not a valid Directory resource in /data/members/paid/m/a/mazalien.nl/htdocs/weblog/gallery/sp_helper_functions.php on line 10 and Warning: Invalid argument supplied for foreach() in /data/members/paid/m/a/mazalien.nl/htdocs/weblog/gallery/sp_helper_functions.phpon line 452.
I hope you know a simple solution. By the way thanks
greetiengs MazAlien
October 19th, 2005 at 9:34 pm
Sorry for the delay in my response, MazAlien… I have gotten that error before. Unfortunately, I don’t remember what caused it; However, we can try to work through as I try to remember. I do remember having trouble when directory names had apostrophes in them, maybe filenames too. So let me know if it does that for all directories. I’m going to look in the file that the error mentions, because I seem to remember modifying it. The error is not because of the integration.
October 19th, 2005 at 9:37 pm
Try changing line 10 to this, if it’s not like this already:
if ($dh = opendir(stripslashes($input_dir))) {October 21st, 2005 at 8:15 am
Hello Dan. I saw your solution. Uptill now I only used the css-style of my blog for the gallery. Not the core of Wordpres because of these errors. So tonight I will try things out and let you know if it worked for me. greetings MazAlien
October 22nd, 2005 at 4:22 am
Dan, I have looked for the line 10 in my ” sp_helper_funtion.php” file. Line 10 contains : while (false !== ($filename = readdir($dh)));
So the first lines of this file contains :
2
3 //THIS FUNCTION WILL RETURN A SORTED ARRAY OF ALL FILES AND FOLDERS IN THE CURRENT DIRECTORY
4 function getDirList($input_dir=”")
5{
6 global $dir;
7 if($input_dir == ”)
8 $input_dir = $dir;
9 $dh = opendir(stripslashes($input_dir));
10 while (false !== ($filename = readdir($dh)))
11 {
12 $files[] = $filename;
13 }
14 @sort($files);
15 return $files;
16 }
So if I replace line ten with your code it would be much the same code lijke line 9. Changing line nine with your code doesn’t solve the problem.
Perhaps you have an other solution.
Greetings mazalien
October 22nd, 2005 at 1:31 pm
MazAlien … could you send a copy of your sp_helper_functions.php to contact@soulpass.com ? i’ll have a look at it and get back to you.
October 26th, 2005 at 2:17 pm
Hi everyone, I just want to thank Daniel for his supoort he gave me on implementing the EHP gallery in Wordpress.
thanks
greetings maza
November 13th, 2005 at 2:01 pm
Hey Dan, after all the trouble I went through trying to get espg to work…finally discovered something better. Check out http://plogger.org it’s pretty sweet out of the box and it works very nicely with FTP uploads for the those large folders.
This other guy wrote a bit about integrating/skinning plogger into a wordpress site.
Jay
November 17th, 2005 at 8:29 pm
Hi,
I’m having a similar issue to the one above, however it happens when I click to change the page at the bottom.
When I click to go to page two … I get two errors repeated:
Warning: readdir(): supplied argument is not a valid Directory resource in /gallery/sp_helper_functions.php on line 10
Warning: Invalid argument supplied for foreach() in /gallery/sp_helper_functions.php on line 452
Now, I’m not using folders for my gallery because I want the pictures to appear in the root.
The link that it’s trying to open is: /gallery/index.php?dir=.&page=2
but everything is fine if i modify the address bar to show: /gallery/index.php?page=2
So basically … it works if I get rid of the dir=.&
Any idea how I can have it stop adding that part to the link?
Thanks,
phil
November 19th, 2005 at 5:53 pm
Phil,
That’s an odd problem… The period in the URL would be a reference to the current directory, and the ampersand is separating the URL arguements. I wouldn’t think there should be a difference whether or not the period is in there. At any rate, if you would like, I can send you my copy of sp_helper_functions.php. That might fix the problem. I have your email address from the form, so you don’t have to leave it on here. Would you like for me to send you the file so you can try that?
-Daniel
November 20th, 2005 at 12:26 am
Hi Dan,
That would be great if you could send me your file. I’ll give it a shot. If that doesn’t help, then I just might start all over again.
Thanks,
phil
September 14th, 2006 at 2:43 pm
There is a way to remove the 2 warning messages. Do this:
1) At line 10: Add a @ in front of the readdir()-function.
eg.
while (false !== ($filename = @readdir($dh)))
2) In the getNumberImages($dir)-function at line 453. Insert a if clause around the foreach-loop:
eg.
if ($dir){
foreach (…)
…
}
However, I also have a problem. If I insert the header.php from this site. The foldername/title and description of the album don’t appear. If I click on a thumbnail in the album view, the whole path (with title) shows. Very strange.
Anyone have a solution to this?
September 15th, 2006 at 9:02 pm
Yes, I suppose this is Wordpress 2.X issue.
No, I am talking about the title of album in the body e.g. Curently viewing: My photoalbum » Holiday-trip » city.jpg. Another problem occured too. It is not possible to navigate the thumbnails. But, however, I fixed both problems.
The problem is that the $dir-variable is probably in conflict with a wordpress $dir-variable. What I did was to change the $dir-variable to something else (e.g. $eSPGdir) in these files: sp_def_vars.php, sp_helper_functions.php and sp_index.php.
September 19th, 2006 at 7:09 pm
Weeeird… well, I’m glad you got it working, and I hope the header still worked for you..
December 6th, 2006 at 6:14 pm
Thank you very much for this guide. It was very helpful. I have given you credit on my webpage :).
February 12th, 2007 at 1:34 am
Hi! Definitely nice and neat site you got there.a
September 6th, 2008 at 9:43 am
Thanks, you nice post that helped me alot.