Restricting Random-Block to or from certain albums?

pdxbrit

Joined: 2005-01-19
Posts: 4
Posted: Wed, 2005-01-19 21:43

Hi Folks,

I finally upgraded to 1.44 so I could get the random block working again, works great btw! I do have a howto question though.

My site has a numerous galleries, and several of them I am hosting for friends. I do not want the random block displaying images from those galleries. Is there a way to do this? I'm using this with a crusty old version of phpnuke (Unsure of the version).

Cheers, Mark.

 
KnightShade

Joined: 2004-03-22
Posts: 13
Posted: Fri, 2005-01-28 20:08

I to would be interested in knowing how to restrict Random Block from choosing a particular album.

If I'm reading things correctly - It looks like the function scanAlbums() could be modified to exclude an album.

Has anyone tried this before?

 
KnightShade

Joined: 2004-03-22
Posts: 13
Posted: Fri, 2005-01-28 21:46

Looks like a google search answered my own question:

http://www.squatty.com/article.php?story=20021007061243579

article wrote:
Ok, to solve your problem it's going to take a bit of editing...
All you need to do is add an if statement. So find the first line in
the code below in your block-random.php.

Then add the if ($name != "wrench1") { <-- Now wrench1 is the name
of the directory I don't want included, this would be your guest album.
Once you add that line you need to put an end } after $cache[$name] =
$numPhotos; like shown below.

It worked for me, it *should* work for you.

I cleaned this up slightly to add an additional condition to the existing if clause.

code wrote:
$name = $tmpAlbum->fields["name"];
if ( ($name != "wrench1") && ($numPhotos > 0)) {
$cache[$name] = $numPhotos;
}

Presumeably this could be altered by someone to only include specific albums as well.

So far it looks like it is working as expected.

 
pdxbrit

Joined: 2005-01-19
Posts: 4
Posted: Fri, 2005-01-28 23:33

Great googling, I missed that.

Thanks, Mark.

 
smerfkila

Joined: 2005-02-26
Posts: 4
Posted: Sat, 2005-02-26 19:16

For those who do not know how to edit code well I put it in this file and commented it for you all.

Enjoy.

 
graffixjones

Joined: 2005-10-13
Posts: 8
Posted: Fri, 2006-07-07 04:57

I tried the code listed above but was still having problems for some reason, but I figured out a way to weed out photos being displayed from 'restricted' albums.

I just included a while loop in the doPhoto() function:

Original doPhoto() function (beginning):

function doPhoto() {
	$album = chooseAlbum();
       if (!empty($album)) {
		$index = choosePhoto($album);
       }

Edited doPhoto() function:

function doPhoto() {
     $album = chooseAlbum();

     while ($album->fields['name'] == "album1" || $album->fields['name'] == "album2" 
              || $album->fields['name'] == "album3" || $album->fields['name'] == "album4") {
        $album= chooseAlbum();
     }
    if (!empty($album)) {
        $index = choosePhoto($album);
    }

This forces the script to continue to re-run the chooseAlbum() function until the album chosen is 'not' one of the restricted albums you have specified... to add extra albums, just use the || (logical 'or') symbol and include $album->fields['name'] == "albumname", of course switching the name of the album you don't want shown.

This works for me... I figured I'd add it since I was just searching around for a way to exclude albums from my random block, but after a bit of code digging I came up with this solution myself.

I hope someone else finds it useful.

 
gjschaller
gjschaller's picture

Joined: 2004-04-19
Posts: 44
Posted: Fri, 2007-03-09 23:59

Hello!

I'm working with this on my gallery, and so far, so good. I have the code:

$name = $tmpAlbum->fields["name"];
if ( ($name != "Awards") && ($numPhotos > 0)) {
$cache[$name] = $numPhotos;
}

However, I am running into an issue with Sub-Albums - I have my main albums, and a series of Sub-albums called "Aawards-YYYY-MM" (with YYYY and MM being the Year and Month - a new one is added monthly). All of those Awards-YYYY-MM albums are grouped under a main album called "Awards".

Now, here's the catch - I excluded the main "Awards" album, but it does not seem to be excluding the various sub-albums, which makes sense. Is there a way to exclude all Awards albums, using a wildcard or such, to weed them out?

I could exclude them individually, but that would mean editing my block-random.php every month when I added a new album. O.O

Thank you!

--
Geoffrey J. Schaller
http://gallery.knightrealms.com

 
agent_dave79

Joined: 2007-05-08
Posts: 2
Posted: Tue, 2007-05-08 14:23

hi there, i'm kind of a gallery newbie and am not so experienced with all the codings.

i tried to manage the random-block, which worked quite fine.
but now i don't quite understand how i can only pic pictures from a specific album with its subalbums.

i found an older post, which is about two years old, showing a very simple example how to do that. unfortunately the newer gallery versions do not support this method anymore.

is ther an official and simple way to do so (for the latest gallery 1)? i tried some of the methods above, but didn't get a working script and to admit, i'm not so familiar with the coding showed above.
for example where do i have to enter the code piece from gjschaller?

Quote:
$name = $tmpAlbum->fields["name"];
if ( ($name != "Awards") && ($numPhotos > 0)) {
$cache[$name] = $numPhotos;
}

would really appreaciate your help.

thx so far
dave