Better way to integrate eSPG into Wordpress

I wanted to integrate Enhanced Simple PHP Gallery into Wordpress 1.5, but also have the ability to have the same gallery and not use wordpress. So that people can go directly to images.dreden.com and you will see eSPG without wordpress, but if you go to

images.dreden.com/wp_index.php you will see the gallery integrated into wordpress. The nice thing with this way is that you can change theme on the fly without editing any files. The way this is explained on the eSPG website uses header.php and footer.php files and it is based on the standard Kubrick theme. So the theme doesn’t change together with wordpress (correct me if i’m wrong here).

If this sounds interesting, read on and i’ll show you how i did it. Its really simple and fully themeable.

If you haven’t downloaded Enhanced Simple PHP Gallery 1.7 yet, you can download it here and install it.

What you want to do first is create a file called wp_index.php.

then

Cut and paste this code into the file wp_index.php:

<style type="text/css" media="screen">

PASTE STYLE HERE

</style>

<?php

/* Don’t remove this line. */
require(’/var/www/htdocs/wp-blog-header.php’);
?>
<?php get_header(); ?>

<div id="content" class="narrowcolumn">

<div class="navigation">
<div class="alignleft"><?php posts_nav_link(”,”,’&laquo; Previous Entries’) ?></div>
<div class="alignright"><?php posts_nav_link(”,’Next Entries &raquo;’,”) ?></div>
</div>

 

<div id="espg">

// Enhanced Simple PHP Gallery START

// Enhanced Simple PHP Gallery END

</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Now look at the line that says:
require(’/var/www/htdocs/wp-blog-header.php’);
and change /var/www/htdocs/wp-blog-header.php to /the/path/to/wp-blog-header.php. Just in case you misunderstood that you have to change it to the full path to the file wp-blog-header.php. In my case the file is in /var/www/htdocs.

Open the file sp_styles.css, select everything and paste it where it says “PASTE STYLE HERE”. The reason for this is so you can have a different styles in Wordpress and the standalone gallery.
Be sure to delete the text “PASTE STYLE HERE”!
Also remove this:

html {
background:#D1ECE8;
}
body{
font-family: arial,helvetica,sans-serif;
font-size:90%;
/*-moz-border-radius:20px;*/
margin:15px;
color:#666;
background:#fefefe;
border:1px solid #bbb;
}

from what you pasted from sp_styles.css

Open the file sp_index.php select everything and copy (CTRL-C) and paste (CTRL-V) in between:

// Enhanced Simple PHP Gallery START

// Enhanced Simple PHP Gallery END

Remove the line:
include(’header.php’);
somewhere at the top where this is:

require(’lang/index.php’);
require(’sp_config.php’);
require(’sp_helper_functions.php’);
require(’sp_def_vars.php’);
include(’header.php’);

and change:

require(’sp_helper_functions.php’);

to:

require(’wp_helper_functions.php’);

Also remove the line at the bottom that says:

< ?php include('footer.php'); ?>

Now copy the file sp_helper_functions.php to a new file called wp_helper_functions.php and change the line:

echo "<strong>".$GLOBALS[’lang_curr_view’]."</strong> <a href=\"" . returnCurrentWorkingDirectory() . "/\"";

to:

echo "<strong>".$GLOBALS[’lang_curr_view’]."</strong> <a href=\"" . "wp_index.php" . "\"";

in wp_helper_functions.php

Save the files in the same directory where all the Enhanced Simple PHP Gallery files are.

Thats it!

Here are examples of the finished files:
wp_index.php wp_helper_functions.php

I have prepared a ZIP file with the two finished files based on Enhanced PHP Gallery 1.7 here

If i have forgotten something, you have any questions or you can’t get it to work. You are welcome to leave a reply below.

39 Responses to “Better way to integrate eSPG into Wordpress”


  1. 1 art May 24th, 2005 at 4:02 am

    Hello,
    I have installed your script but keep getting the following error when uploading.

    Warning: fopen(sp_descriptions.ini): failed to open stream: Permission denied in /home/******/public_html/gallery/sp_helper_functions.php on line 486

    The images upload anyway, I can view the full size images, but the thumbs do not show.

    When trying to edit any information, folders or subfolders, I get the following errors:

    Warning: fopen(sp_descriptions.ini): failed to open stream: Permission denied in /home/jartbyme/public_html/gallery/sp_helper_functions.php on line 486

    Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/gallery/sp_helper_functions.php:486) in /home/******/public_html/gallery/header.php on line 2

    Can you shed any light, please. Thanks in advance. Great work, by the way. :)

  2. 2 dreden May 24th, 2005 at 7:02 am

    If you have your own server “chown nobody.nobody sp_descriptions.ini”,
    if you uploaded via ftp and you do not own the server/are admin
    “chmod 666 sp_descriptions.ini”. What this does is to make the file writable by the web server.

    If you don`t know how to do this, look here

    Did you remove the line:
    include(’header.php’);
    somewhere at the top of wp_index.php ?

  3. 3 art May 24th, 2005 at 5:04 pm

    chmod 666: check
    include(’header.php’); removed : check

    problem persists, plus when creating new subfolders:
    /home/******/public_html/gallery//newsubfolder
    Note the double slash preceding the new folder, accompanied by Permission denied in /home/******/public_html/gallery/sp_editor.php on line 238

    I’m pretty sure that I saw the “double slash” issue at the SPG forums. I’ll have a browse there again. The other weird thing is that I had to delete the call for sidebar out of the wp_index, because it was being centered. As soon as I removed it, I am now getting the sidebar still, but it is in its propper position. So to sum up:
    1. no thumbs
    2. cannot create/edit via web, only via ftp or serverside
    3. I’m really, really liking this more and more :)

  4. 4 art May 24th, 2005 at 5:12 pm

    P.S. I’m also trying to figure out how to remove the sidebar from the gallery index. :)

    thanks again

  5. 5 dreden May 24th, 2005 at 6:19 pm

    Do you have these problems with sp_index.php also?

  6. 6 art May 24th, 2005 at 7:02 pm

    Dreden, these problems are specifically in ap_index.php, in other words in the gallery propper. I do not have any editing links or options in wp_index. Another strangeness, every other time at the sign in screen in gallery propper, I get Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/gallery/validate.php:27) in /home/******/public_html/gallery/header.php on line 2. It still lets me sign in after that though. So to sum up, I can now upload files, edit folder info, but cannot create folders and cannot see thumbs. Thanks for getting rid of half the headache so far, dreden. :)

  7. 7 art May 24th, 2005 at 7:03 pm

    ^oops, that first line was supposed to read sp_index, not ap_

  8. 8 dreden May 24th, 2005 at 7:31 pm

    open up gd_detect.php in the browser see what it says and make sure
    $gd_version = ” “; at the bottom of sp_config.php contains the same version number

  9. 9 art May 24th, 2005 at 7:49 pm

    did that yesterday, dreden. $gd_version = “2.0.28″;
    that doesn’t seem to be the culprit. I have also checked permissions on the cache and rcache folders, had them at 775, then 777.
    The weirdness continues, because it seems that whatever changes I make to any file or folder permissions, the result is not instant, but seems to come after a while. I just went back and the image that I uploaded this morning is now showing up its thumb, while the other ones from yesterday do not. What I will do is re-upload the other images and wait and see what happens. I’ll pretend to go away and come back, since the server likes to play hide and seek with me it seems. LOL!

    also, is there any easy way of getting rid of the sidebar in wp_index? I got rid of the call to sidebar, remember, but it is still pulling it from somewhere. Thanks again! :)

  10. 10 dreden May 24th, 2005 at 8:40 pm

    Remove the line that contains “get_sidebar()” at the bottom, but you already did that?
    I just tested it and my sidebar was removed.

    What server are you running this on ?

  11. 11 art May 24th, 2005 at 10:12 pm

    server is linux/apache with most popular modules
    … and yes, I removed that line from wp_index, so I have no clue where it is being called from. I’m working with the daisyrae theme, but that shouldn’t really make a difference.

  12. 12 Flipthedolphin May 30th, 2005 at 11:57 pm

    mmh…
    I’m getting this weird error

    Parse error: parse error, unexpected T_STRING in /home/flipthed/public_html/espg/wp_index.php on line 421

    my 421 line is:

    dunno…

  13. 13 Flipthedolphin May 31st, 2005 at 12:18 am

    ok dudes… I’ve figured it out: the code on this blog is wrong. I’ve used the right code in the PHPs files though… and now kinda works…

    but I get these errors now:

    Warning: main(rotator.php): failed to open stream: No such file or directory in /home/*****/public_html/espg/wp_index.php on line 414

    Warning: main(rotator.php): failed to open stream: No such file or directory in /home/*****/public_html/espg/wp_index.php on line 414

    Warning: main(): Failed opening ‘rotator.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/*****/public_html/espg/wp_index.php on line 414

  14. 14 Flipthedolphin May 31st, 2005 at 12:19 am

    what a dumbass… I don’t need a rotator.php…
    see what happens when you code late at night??? :D

  15. 15 Bekah May 31st, 2005 at 3:41 am

    Just a question… I am a beginner at PHP and am wondering where exactly I am supposed to put my edited files, and am I to upload them via FTP?

  16. 16 dreden May 31st, 2005 at 7:34 am

    Bekah: You put them in the same directory as where your enhanced simple php gallery are. You can download it here

  17. 17 dreden May 31st, 2005 at 7:35 am

    Flipthedolphin: doesn’t cause an error if rotator.php isn’t found. What do you mean, the code is wrong?

  18. 18 Flipthedolphin May 31st, 2005 at 12:28 pm

    if you copy and paste the text on this post into a text file your get

    but you should get

    which is different in the “‘” things…
    you can get the right code only if you watch the PHPs files.

  19. 19 Flipthedolphin May 31st, 2005 at 12:31 pm

    oh damn…
    I forgot those dummy “code” tags…

    well… there is a slight difference between the code you reported here on you blog and the code that we can read in the phps files.

    the phps files are correct. the code here is not.

    the error is in the navigation divs: alignleft and alignright.
    the “‘” are different and those on this post are wrong. Those in the phps file are correct.

  20. 20 dreden May 31st, 2005 at 2:22 pm

    I was afraid that would happen, i had some problems getting the code to display correctly on this page.

  21. 21 Bernardo May 31st, 2005 at 10:27 pm

    Please help me, i install eSGP, but, i need you eSGP Gallery without sidebar what use width 100%……
    Tell me how i can make it please….

  22. 22 dreden Jun 1st, 2005 at 8:11 am

    remove < ?php get_sidebar() ?> in wp_index.php

  23. 23 Bernardo Jun 1st, 2005 at 2:43 pm

    sorry by my poor english… i’am from CHILE, i speak spanish….
    Ok, I did what you say to me, but it is not even to me…
    Please, help me…
    This is my page http://www.ligabc.dm.cl/portal/album/wp_index.php

  24. 24 Langouste Jun 15th, 2005 at 2:25 pm

    Good job ! It helped me a lot ….

  25. 25 Soeren R Jul 1st, 2005 at 5:52 pm

    I get this error when i try to enter the wp_index.php-file:

    Fatal error: Call to undefined function bloginfo() in /usr/home/web/webxxxxx/wp-content/themes/pool/header.php on line 5

    Fatal error: Call to undefined function get_header() in /usr/home/web/webxxxxx/galleri/wp_index.php on line 411

    In your tutorial you write the following:

    Now look at the line that says:
    require(’/var/www/htdocs/wp-blog-header.php’);
    and change /var/www/htdocs/wp-blog-header.php to /the/path/to/wp-blog-header.php. Just in case you misunderstood that you have to change it to the full path to the file wp-blog-header.php. In my case the file is in /var/www/htdocs.

    I am not familiar to this way of writing a path. The header file I want to use has got this URL http://www.hoejlundcarlsen.dk/wp-content/themes/pool/header.php so what should I write in the wp_index.php file to make it recognize my header?

  26. 26 dreden Jul 4th, 2005 at 12:03 pm

    /usr/home/web/webxxxxx/wp-blog-header.php

  27. 27 lowell Jul 8th, 2005 at 2:37 am

    hello there!

    dreden could you tell me what the is the problem with my site.. I did everything you said in your tutorial but still I couldn’t figure it out…

    here’s my site http://www.lvtair.com/gallery

  28. 28 kiss Jul 18th, 2005 at 8:22 pm

    im almost done but I have error

    Parse error: parse error, unexpected T_STRING in /home/kiss/public_html/gallery/wp_index.php on line 419

    below is the line 419

  29. 29 SlackeR Jul 19th, 2005 at 11:59 am

    the page seem to be showing up nice at http://slacker.ph/blog/gallery1 but how to I pull it off my main page? http://slacker.ph/blog

  30. 30 SlackeR Jul 19th, 2005 at 12:19 pm

    ok nevermind figured it out stupid me… so you call wp_index.php

    http://www.slacker.ph/blog/gallery1/

  31. 31 SlackeR Jul 19th, 2005 at 12:24 pm

    http://www.slacker.ph/blog/gallery1/ is working fine but http://www.slacker.ph/blog/gallery1/wp_index.php is all but plain lynx browser format

  32. 32 dreden Jul 19th, 2005 at 1:57 pm

    Have you edited the line that says:
    require(’/var/www/htdocs/wp-blog-header.php’);
    ?

    This needs to be set to the full path to the file wp-blog-header.php

  33. 33 SlackeR Jul 19th, 2005 at 9:43 pm

    yups done that i even added /home/my home directory here/public_html

  34. 34 kiss Jul 20th, 2005 at 11:03 pm

    hello there below is the line that has problem dunno what to do
    i have no php background apprecaite all the help…

    how could i fix it?

    div id=”content” class=”narrowcolumn”>

    div class=”navigation”>
    div class=”alignleft”>
    div class=”alignright”>
    /div>

  35. 35 dreden Jul 21st, 2005 at 10:03 am

    <div id=”content” class=”narrowcolumn”>
    <div class=”navigation” >
    <div class=”alignleft” > <?php posts_nav_link(”,”,’« Previous Entries’) ? &gt < /div >
    <div class=”alignright” > < ?php posts_nav_link(”,’Next Entries »’,”) ? &gt < /div >
    </div >

    </div >

    fix the ‘

  36. 36 MazAlien Oct 14th, 2005 at 6:57 pm

    Hello dreden. I have followed your instructions regarding implementing the enhanced gallery. But the gallerysite remains blanco. I have put the full serverpath for the wp-blog-heather file. And still nothing shows up. The normal gallery indexfile works but it would be great if you know what the promblem is why it stays blanco. When looking at the source code only the css-code is there. greetings MazAlien

  37. 37 Bernardo Nov 22nd, 2005 at 4:24 am

    Please, help me. i install wp_index.php, but i call wp_index.php, but not see the header the gallery is http://adictochile.pandela.net/galeria/wp_index.php and the web is http://adictochile.pandela.net…

    Please help me…

  38. 38 Adam Jul 24th, 2006 at 1:15 am

    Sir

    I replaced

    require(’/var/www/htdocs/wp-blog-header.php’)

    with

    require(’/home/termina/public_html/wordpress/wp-blog-header.php’)

    and a couple of other tries and got the following errors:

    Warning: Division by zero in /home/termina/public_html/gallery/wp_index.php on line 363

    Warning: Division by zero in /home/termina/public_html/gallery/wp_index.php on line 363

    Warning: main(0php�): failed to open stream: No such file or directory in /home/termina/public_html/gallery/wp_index.php on line 363

    Warning: main(0php�): failed to open stream: No such file or directory in /home/termina/public_html/gallery/wp_index.php on line 363

    Warning: main(0php�): failed to open stream: No such file or directory in /home/termina/public_html/gallery/wp_index.php on line 363

    Fatal error: main(): Failed opening required ‘0php�’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/termina/public_html/gallery/wp_index.php on line 363

    Line 363 is the line with require(’/var/www/htdocs/wp-blog-header.php’)

    Any suggestions? Thanks.

  1. 1 ChrisBunting.com » Blog Archive » The hunt for gallery software Pingback on Jun 10th, 2005 at 4:55 am

Leave a Reply

You must login to post a comment.




RSS Entries and RSS Comments