How to include ZP in a site index.php (home) page?

Let's say I install ZP in a /gallery folder, below my site root.
The site root has an index.php file which is a simple home page with a menu like this: Home Blog Gallery About.

The /gallery will contain all the ZP files: index.php, albums.php, etc. The "Gallery" menu entry would call the ZP index.php file so that I can have the full ZP functionality.

On my home page I just want to pull thumbs from any single ZP albums folder into my index.php home page. I would do this using the printRandomImages or any other function that would allow me to do that. (Then I would want to display the single images from the thumbs).

*** The question is, what do I have to include at the top of my site root index.php file to be able to then use the ZP functions and achieve the above?

I searched the user guide and the forum but so far I did not find anything on this.

Comments

  • You could try taking a look here. This is the "How to use Zenphoto as a plugin" tutorial. I don't believe it will function right if your main site is built in wordpress though (not sure if that's been fixed).
  • acrylian Administrator, Developer
    It is not fixed as it is not our fault. It is because of changes in Wordpress. Wordpress does not call template pages "directly" anymore since 3.x (I think). It calls them through a function which means all global variable contexts Zenphoto needs to work are cleared by doing that. This might be the case with other systems as well.

    This is nothing we can do to fix since Zenphoto is considered to be a standalone system. Sorry.

    The only way would be to declare all globals Zenphoto might need within Wordpress (which might require hacking it). Or building workarounds like we do on our homepage (it is btw planned to move the site to Zenphoto only once we find the time).
  • Oh, for now I'd only like to call ZP from a simple index.php file in my site's root folder, not from Wordpress. Is there any way to do that? I mean, If my site index.php has the right includes, couldn't it call and run the ZP functions I need?
  • Have you looked at the link micheall provided?
  • I did now, thank you micheall for the link, I think that is exactly what I need. I will try it out.
  • acrylian Administrator, Developer
    Of course if you use a plain index.php file without any other CMS that should still work. Probably just over explained a little..;-)
  • I tried to display the thumbs for a single album on the index.php page om my ZP insallation; I used
    `


    <?php zp_load_album('/zenphoto/Latest') ?>

    `
    to load the album specific single context, followed by the
    `


    <?php while (next_image(false, $firstPageImages)): ?>

    ...
    `
    loop to display the album thumbs. it did not work.
    I get a blank page, no thumbs.

    My index.php works fine if I use the typical loops:
    `


    <?php while (next_album()): ?>

    ...

    `
    or
    `


    <?php while (next_image(false, $firstPageImages)): ?>

    ...
    `
    Again, what I am trying to do is to display on the index.php home page the images from a single folder that I want to be able to specify. In this test the index.php is in the ZP themes folder.
  • PS. The were added by the forum when I edited the post. I could not further edit it, the forum is extremely slow, it takes minutes to load.
  • acrylian Administrator, Developer
    Yes our site is under heavy traffic every now and then and lot of spammer register to the forum to missuse our profile pages as link depository (via Twitter for example). Too bad that they did not read the notes on registering that no one will be able to see that. (I don't know what you mean the forum has added).

    Anyway, to the topic. What you does and can simply not work. `/zenphoto/Latest` would be an subalbum "Latest" within an album "zenphoto" within the `albums` folder. You have to setup the object global of the current album (the global `$_zp_current_album`) use the object model framework to get this working. Please read http://www.zenphoto.org/2010/02/zenphotos-object-model-framework/
  • Thank you for the hint. I read the object framework and I tried this:
    `

    <?php $galleryobject = new Gallery(); ?>

    <?php $albumobject = new Album($galleryobject,"latest"); ?>

    <?php while (next_image(false, $firstPageImages)): ?>

    ... standard image loop code that works ...

    `

    "latest"is the name of the individual folder within the ZP "albums" folder. Again, it did not work.

    By the "forum added" I meant the `` shortcodes in the code.

    On spammers: your site does a very good job though in getting rid of the spam. If waiting a few minutes is what it takes, no problem.

  • acrylian Administrator, Developer
    You have to setup the global for the current album using `makeAlbumCurrent($albumobject)`. Then `$_zp_current_album`contains the album object you just setup.
  • Many functions, such as `next_image()` work only if all the correct context is setup. Fortunately, what you want to do has been anticipated. Usethe function `makeAlbumCurrent($albumobject)` to setup the context before the `next_image()` loop.
  • Bingo!!! Here's the code for anybody else who wants to display thumbs from a specific album:

    `


    <?php $galleryobject = new Gallery(); ?>

    <?php $albumobject = new Album($galleryobject,"Bikes"); ?>

    <?php makeAlbumCurrent($albumobject) ?>

    <?php while (next_image(false, $firstPageImages)): ?>

    ... loop code
    <?php endwhile; ?>

    `
    Inside the loop I used the getCustomImageURL() so that I can display the larger image in a lightbox. To display it using image.php replace it with getImageLinkURL()
Sign In or Register to comment.