Elegant solution to too many Sub Albums...

Gaza

Joined: 2004-08-25
Posts: 6
Posted: Wed, 2004-08-25 19:41

This thread had a number of solutions to the problem of having too many sub-albums, however I didn't like any of them as they distracted from the feel of gallery. As a result I implemented some quick iframes changes to the source, which allows for a scrolling pane for the sub albums (if they are too big to fit in the cell), but keeps the style of the orginal gallery.

This change also speeds up the displaying of your root gallery because it doesn't have to recursively find all the sub albums on the page load. The iframes load seperately from the main page thus load after the fact.

A demo of the implementation can be found here: http://gallery.tvg.ca:8080/

To implement this is really simple.

1. Create a file called albumTree.php in your root gallery directory with the following code:

<?php
require(dirname(__FILE__) . '/init.php');
$albumName = $_REQUEST['albumName'];
?>
<html>
<head>
<?=common_header();?>
<BASE target="_parent">
</head>
<body class="albumdesc">
<?=printChildren($albumName);?>
</body>
</html>

2. Open album.php in your root gallery folder and find the following line (in version 1.4.4 (pl1, not sure) it is on line 396:
<?php echo printChildren($albumName); ?>
And change it to:
<iframe src="albumTree.php?albumName=<?=$albumName?>" width="100%" height="100%" frameborder="0"></iframe>

And you are done, that simple. If you want, you can change the height of the iframe from "100%" to something suitable for your gallery skin, ie I use "200".

Let me know what you think and if you have any changes/additions.

Cheers,
Tys von Gaza
http://tvg.ca/

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Thu, 2004-08-26 00:12

I have done this to my gallery, and I have to say I love it. For albums with tons (or even just more than 10 or so) it makes the gallery look a lot smoother.

One suggestion though, with the "100%" for both entries, on my gallery I could not see the iframes at all. I thought I had boned something up. If you set them to something like 100 x 100 it would at least maybe make sure they are there... and let people know they need to tweak em :)

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Thu, 2004-08-26 00:32

A small tweak would be to add the following above your iframe in albums.php

<strong>Sub-albums:</strong><br />

... and comment out the following which is found in util.php. As an asside what does the _("Sub-albums") portion do, pull the language file's version of "sub-albums"? It just doesn't look like a normal php variable to me.

if ($depth==0 && !$printedHeader++) {
  echo "<strong>". _("Sub-albums") .":</strong>";
}

Of course, what all this does is put the word "Sub-albums:" directly above the iframe instead of inside it, which means even if people have scrolled... they will still see the "Sub-albums" thing. You can see what I mean at http://fryfrog.com/gallery/

 
Terje-
Terje-'s picture

Joined: 2004-01-20
Posts: 90
Posted: Thu, 2004-08-26 10:54

This is cool, but do remember that if you have a lot of albums 100+, this will make the root album extremly slow. Having sub-albums show on the root page, gives me a 800% slowdown. My gallery: http://www.mrx.no/

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Thu, 2004-08-26 15:57

If you are running 1.4.4-pl1, open your config.php and look for the line below. If it says "yes" change it to "no". If you are running an earlier version about 1.4.3-1.4.4 check out this thread for some code changes you can do.

$gallery->app->slowPhotoCount = "no";
 
Gaza

Joined: 2004-08-25
Posts: 6
Posted: Thu, 2004-08-26 17:27
fryfrog wrote:
A small tweak would be to add the following above your iframe in albums.php

The only problem with this is if an album has no sub-albums then the title will still show, where as if you keep it in the iframe then only the albums with sub albums will show the title.

 
Gaza

Joined: 2004-08-25
Posts: 6
Posted: Thu, 2004-08-26 17:30
Terje- wrote:
This is cool, but do remember that if you have a lot of albums 100+, this will make the root album extremly slow. Having sub-albums show on the root page, gives me a 800% slowdown. My gallery: http://www.mrx.no/

The plus side of this change is that displaying of the sub albums doesn't happen on the root page anymore. The root page will load fast and call each of the album's iframe's, which will then load through a seperate http call.

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Thu, 2004-08-26 18:22

Gaza, I tested what you mean. I don't have any main albums w/o at least 1 sub album so I didn't even think of or see it. It is indeed a drawback, and I don't see any way around it. I guess it boils down to which you like visually :)

Also, he is dead on about load times. Even if you have the slow counting of album hits turned ON (and your albums.php normally loads in 30 sec), it will be much faster with the iframes.

Right now, when I load the page the thumbnail highlights AND the sub-albums load at about the same speed down the page. Previosly, the ENTIRE page would just not render until it was all done.

These are the results of the following command run with slow photocount ON and OFF. I also use a php optimizer called "mmcache". From the results below, using the iframe seems to allow slow count to be enabled with almost no impact on main page load time.

That being said, you have to see the page load to see what it does. The main page loads fairly quickly, but the "iframes" are like little pages inside the main page. Each of these pages has to load also and THAT does take a little longer. As you watch the screen, they tend to fill in at about the same rate the thumbnails do.

If you would like to see what I mean, you can look at http://fryfrog.com/gallery/ and watch the behavior. I have left the slow count ON so that it is a little more emphasized.

Slow Count ON

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  4150 4382 320.1   4315    4932
Waiting:      320  341  13.2    349     352
Total:       4150 4382 320.1   4315    4932

Slow Count OFF

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  4136 4161  27.0   4168    4193
Waiting:      322  338  12.1    343     351
Total:       4136 4161  27.0   4168    4193
 
thechadd

Joined: 2004-08-23
Posts: 23
Posted: Thu, 2004-08-26 20:28

Is there a way not to use the background from the main page? I have one of the blade skins and the top left image is too dark to read text over when reproduced in each iframe.

 
Gaza

Joined: 2004-08-25
Posts: 6
Posted: Thu, 2004-08-26 23:35

Yes, you can do what formatting you want to albumTree.php, like add your own style sheet and change the body's one to yours.

 
anonymous11234

Joined: 2002-12-05
Posts: 135
Posted: Fri, 2004-08-27 17:49

I did this mod to my gallery as you say, but the sub-albums do not scroll. Do you know how I can fix that.

http://woodshopphotos.com/gallery/

Thanks,
Chris

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Fri, 2004-08-27 18:28

The only one with sub albums long enough DOES scroll, but it doesn't have scroll bars. I can put my mouse over top of it and mouse wheel scroll it. Search google for iframes and how they work, there is an option to turn on / off scroll bars (or put it in auto).

 
anonymous11234

Joined: 2002-12-05
Posts: 135
Posted: Fri, 2004-08-27 18:38

Got it, thanks!

 
coreybyrnes

Joined: 2004-11-06
Posts: 20
Posted: Tue, 2004-11-09 18:22

this is the best solution to having lots of sub-albums... i love iframes...