Random Photo not working on 'sub-directory'.

Hi!

I have a site, e.g. www.michaelsite.com/michaelspages/wordpress which displays a random thumbnail and does so rather well :)

However, I also want to display it in my zenphoto directory, so if I type in:
www.michaelsite.com/michaelspages/zenphoto/gallery1 the random photo will appear, however, this does not work. When I right-click the image to see the src, it has an extra 'zenphoto' in the address :(

How do I get around this issue?
Is it to do with my 'template-functions.php' file?
Or is there a bit of PHP I can do to eliminate any 'extra' zenphotos from the image src address.

Basically my use of the printRandomImages function is in a small php file held in www.michaelsite.com/michaelspages which then does the function and displays the pic - is this causing the issue?

Many thanks for any help.

Am happy to supply a link, if it could be removed at a later stage.

Comments

  • acrylian Administrator, Developer
    Did you set the right home (main) page path in the zenphoto options? That needs to be a full path like http://www.michaelsite.com.
    Did you use the "zenphoto as a plugin" solution from our extenstions page?

    I guess it would be easier if you post a link, we of course can remove it later if you wish.
  • Thanks for the reply :)

    OK.

    As you can see bottom left:
    <link removed> it works great

    However as you can see bottom left:
    <link removed> it doesn't work :(

    The file I'm using(that stores the printRandomImages() function) is at: <link removed>

    The code for 'test.php' is:

    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    if (stristr($_SERVER['REQUEST_URI'], 'zenphoto') == true ) {

    define('WEBPATH', '../flannigan');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    } else {

    define('WEBPATH', '../zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    }

    ?>

    <?php<br />
    echo '
    ';

    echo '
      ';
      printRandomImages(1);
      echo '
    ';

    ?>`

    Any help at all, you can give, would be brilliant.

    Thank you.
  • acrylian Administrator, Developer
    It's has clearly to do with the WEBPATH, but I just don't see right now...

    Did you try exactly the solution "zenphoto as a plugin" on our extensions page: http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin

    I have to admit I never tried that personally...(I just built two themes....;-))
  • Yes, it's definitely the webpath. It seems to add that extra 'zenphoto' to the path, where it's not needed :(

    I'm now using:

    `

    <?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', '../zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    ?>

    <?php<br />
    echo '
    ';

    echo '
      ';
      printRandomImages(1);
      echo '
    ';

    ?>`

    But still the same error :(

    Any ideas?
  • acrylian Administrator, Developer
    Yes, please try that. Can't do much more than not working, right?..:-) This is a common way to combine for example wordpress and zenphoto and has been done several times. We use it that way on zenphoto.org, too (to be exact that part aitf311 did set up).
  • Please see ammended post above.

    I used that but still got the same error.
  • acrylian Administrator, Developer
    Ah, try this, set for WEBPATH your full basic path `http://www.domain.com".

    Well, I fear I am not gaining any glory from this today...I guess we better wait until one of my fellow devs who actually used it himself appears...
  • I got an error

    `Fatal error: Call to undefined function: printrandomimages() in on line 10`

    With the code

    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', '');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    ?>

    <?php<br />
    echo '
    ';

    echo '
      ';
      printRandomImages(1);
      echo '
    ';

    ?>`

    Hmm, I'm tearing my hair out here.
  • What version of Zenphoto are you using? the Stopdesign theme prints random images, check out its index.php and look at lines 88 - 96
  • How do I check what version it is?

    I see the Stopdesign code(it also doesn't work when I take it down to to the zenphoto directory). I just don't know why it can display a random image on one part, but not the other :(

    Is it because my 'test.php' is in the WordPress folder?

    Would it make more sense to have ZenPhoto in the 'wordpress' directory, so it'd be wordpress/zenphoto/
  • try
    `define('WEBPATH', '/flannigan/zenphoto');`
  • Re: AlexWilson

    Tried that, but got a very ugly error:

    `Warning: main(/flannigan/zenphoto/zp-core/template-functions.php) [function.main]: failed to open stream: Operation not permitted in /home/mysiteuk/public_html/flannigan/wordpress/test.php on line 4`
  • acrylian Administrator, Developer
    Yes, try placing zenphoto within the wordpress folder.
  • Sorry to be such a newbie on this, but should it just be a case of moving the directory, to be under wordpress, or should I have to make any tweaks in the admin part?

    You have all been very patient, and hopefully this resolves the issue.
  • Man, no matter what I do, it won't work :(

    I've now got it so 'zenphoto' is below my 'wordpress', but it's still adding the 'zenphoto/eric-flannigan' part TWICE to my URL, when in zenphoto :(

    E.g visit: <link removed> - look at the random pic, bottom left and look at the img src for it. :(

    I'm losing the will to live. Someone please help me out :)

    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    ?>

    <?php<br />
    echo '
    ';

    echo '
      ';
      printRandomImages(1);
      echo '
    ';

    ?>`
  • The include line, referencing the 'test.php' file is actually in the 'header.php' file in my WP theme folder.

    I use the same 'header.php' for my WP as I do for ZP.

    Would this cause a problem?
  • GOT IT WORKING!!!

    Runs off to play Boston - More than a Feeling so loud, it'll become popular again :D

    Moderator:
    Please remove the links to my temp site. Thanks!

    Thank you once again for all your input.

    In the end, I made two 'test.php' files and tweaked one of them.
  • acrylian Administrator, Developer
    Great! I have removed the links.
  • Many thanks.
  • Oh, and can you also remove the F words from my posts ;) The surname that is, nothing else eheheh

    Thanks, you're a star!
Sign In or Register to comment.