How I bypass the index page and go to the album page

I need to bypass the index page because only one album will be used - no need to list the one album on the index page.

So, what I did was remove everything inside the index.php file except, `<?php if (!defined('WEBPATH')) die(); ?>`

Then, under that very first line, add the following lines:
`

ob_start();

// Redirect index.php to the album page b/c we don't need a list of

// available galleries since we are dealing with only one gallery

if (getNumAlbums() == 1){

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://www.your-website.com/zenphoto/your-gallery/");

}

`

Brief explanation:
`ob_start();` seems to eliminate any php header problems

`if (getNumAlbums() == 1){` Tests if there is only one Album set up

`header("HTTP/1.1 301 Moved Permanently");` Search engine friendly php redirect
`header("Location: http://www.your-website.com/zenphoto/your-gallery/");`
You will need to modify the location to point to the album you want loaded.

It will look like this:
`<?php if (!defined('WEBPATH')) die(); <br />
ob_start();

// Redirect index.php to the album page b/c we don't need a list of

// available galleries since we are dealing with only one gallery

if (getNumAlbums() == 1){

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://www.thewebdesignloft.com/V.Freyermuth/zenphoto/testing/");

}?>`

To be safe, you can put the above code at the top of the index.php file and above the original file contents. That way, if in the future, you create more than one album, everything will still work... :)

So, you might add this to the end of the above code, above the closing php tag (`?>`):
`if (getNumAlbums() >= 1){

and then add a closing bracket at the bottom of the html code:
</body>
</html>
<?php }?>

Hope this helps someone... :)
Sign In or Register to comment.