[SOLVED] Dynamic albums (last updated albums) : display child albums only (sub-albums) ?

MFNO

Joined: 2007-12-13
Posts: 63
Posted: Fri, 2010-10-22 21:47

[Please note that I added a message in the very end of this topic to sum it all up so that any person that has the same issue I had can have the solution easily]

Hello,

I am using the dynamic albums module, showing the last updated albums, and it's great.

Problem is, it's a gallery of music concerts, and it works like this :

- artist 1 album
____ artist 1 concert 1
____ artist 1 concert 2

- artist 2 album
____ artist 2 concert 1
____ artist 2 concert 2
____ artist 2 concert 3

See it by yourself here (work in progress) : http://www.laurent-photo.com/main.php (dynamic albums are in the "news" frame on top).

Problem is, when I add a new concert from a new artist, I need to create a new album (artist 3) AND a concert album as a sub-album (child) for this album.

And, as you can notice for yourself, the dynamic album module displays both the parent album AND the child album. While the REAL updated material is featured in the sub-album only.

Is there a way I can only display sub-albums in this dynamic album module ?

Please be aware I don't know any thing about coding. I know a bit of html so that I can change .tpl files here and there for design purposes, but not real programming.

I've also searched the forums for hours and couldn't find anything about this...

Thank you for your help, I can't release this website like it is right now...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-10-22 22:29
Quote:
Is there a way I can only display sub-albums in this dynamic album module ?

every album you create in gallery is a sub-album, there is only one top level album, the rest are subs.

But my mediaBlock has more options.
as does my minislideshow.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Fri, 2010-10-22 22:43

Thank you suprsidr.

I've browsed through mediablock and minislideshow webpages, but I can't see how it could help me achieve what I want to do ? I understand mediablock offers a few more options for dynamic albums, but none of them seem to help me in any way achieve this.

Wouldn't there be a way to display only a certain "kind" of albums maybe, if they are all considered sub-albums the same way ?
I don't know, for instance :
- only display albums which have a parent album
- only display albums which DON'T have child albums
- only display albums which actually contain pictures (and not sub-albums)

Just a few ideas, really, I can't seem to figure out how I could do that....

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-10-22 22:50

in gallery admin -> dynamic albums you can set to show only data items, and you can have mediaBlock show particular albums.
http://www.flashyourweb.com/gallery2/mediaBlock.php?g2_itemId=32&mode=dynamic&g2_view=dynamicalbum.RandomAlbum
Album w/ id of 32 is my Images album

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Fri, 2010-10-22 23:10

I'm sorry, really, but I just don't understand what media block exactly is : I've read the pages over and over, I don't know how it works in Gallery, what it's for (I understand it's useful for PHP websites, Joomla, etc... but my website is plain Gallery, no embedding at all, and I don't know anything about PHP). I've read parts of the forum, the whole pages, links, etc... (the wiki link is dead it seems).

But anyways, I tried my best at it, so considering I could install mediablock in my gallery, how could I then add a block of the 3 last updated albums like I want to ? Do I need to select the id of the ones I choose ? Would I then have to type in the .tpl files the specific code (itemId) of the albums I want to display every time ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-10-23 04:10

mediaBlock is for showing gallery content outside of gallery(or where ever you want) with a simple gallery-url type format.

BTW I happen to be the gallery2 site integration expert.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sat, 2010-10-23 08:35

So I understood well, right ?
I am not supposed to use mediablock if I only use gallery itself with no integration at all. Am I right ?
English is not my native language, so I am not sure I understand every thing, hence my weird questions sometimes.

But anyways, if something exists that can be done outside of Gallery through Gallery, I don't understand it couldn't be done directly in Gallery, even with some code...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-10-23 13:06

you can use mediaBlock in gallery templates:

{php}@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_itemId=7&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=4&useThumb=1&column=4');{php}

to configure mediaBlock for your site, you would edit line 28 of mediaBlock.php to:
$ret = GalleryEmbed::init(array('fullInit'=>false, 'embedUri'=>'http://www.laurent-photo.com/main.php', 'g2Uri'=>'http://www.laurent-photo.com/'));
and upload to http://www.laurent-photo.com/mediaBlock.php and to test it visit:
http://www.laurent-photo.com/mediaBlock.php?g2_itemId=7&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=4&useThumb=1&column=4

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sat, 2010-10-23 15:43

I'll try this then, but it's very tough for me, all I have is a PHP file and I don't know any PHP. Isn't there any FAQ, user's doc, explanations, etc... ? The forum is useless for me, it's mostly questions about integration in wordpress, joomla, etc...

I appreciate your help and your detailed information, but it's very difficult for me... I'll give it a try...

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sun, 2010-10-24 23:30

Hello suprsidr

I tried your solution, and I spent like 1 hour 1/2 figuring out you just forgot the "/" in {/php} at the end of your inserted code... That's how bad I am at code !

But in the end I figured it out, as you can see here : http://www.laurent-photo.com/main.php

First "line" with the "NEWS" block is my previous one, the gallery one, I kept for reference.

The one below is generated by mediablock.

My 2 main problems are :

- those are PICTURES shown, not ALBUMS. I just don't understand this, as the code seems to mention albums, not images... Weird. Any clue to this ?

- they are all "glued" to each other in the middle of the frame, could you tell me where I could change that part of the design code ? This whole mediablock.php file is really difficult to understand for me... I could use some help...

Thank you !

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-10-25 00:11

As albums are just a representation of a container and have no physicality I filter them out by default. If one album had no thumb it could messup the whole script.
That said, your going to need to comment out a couple of lines of code.
in function getDynamicChildIds line~272 change from:

                if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                }

to:

                //if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                //}

you'll find those lines in other function if you start using other display modes too.

Quote:
they are all "glued" to each other in the middle

look to function getSimpleDisplay and look for the <table>(line ~521) and adjust to width="100%"
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Mon, 2010-10-25 18:02
suprsidr wrote:
your going to need to comment out a couple of lines of code.
in function getDynamicChildIds line~272 change from:

                if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                }

to:

                //if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                //}

you'll find those lines in other function if you start using other display modes too.

I did that on line 272 ==> not a single change ! Still the same, no improvement.

Should I understand from your last sentence that I need to do this every time those lines appear in the code ?

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Mon, 2010-10-25 18:07

By the way, did you really mean this :

Quote:
//if (!($childItem->entityType == "GalleryAlbumItem")) {
$display .= getDisplay($childItem);
//}

or this :

Quote:
//if (!($childItem->entityType == "GalleryAlbumItem")) {
// $display .= getDisplay($childItem);
//}

I don't know anything about PHP, but it seems different (don't you worry, I tried both on my test up here).

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-10-25 21:52
Quote:
I did that on line 272 ==> not a single change ! Still the same, no improvement.

did you set the dynamic album module to output only album items? gallery admin -> dynamic albums.

BTW, I don't appreciate your tone.

unsubscribing.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Mon, 2010-10-25 22:10
suprsidr wrote:
BTW, I don't appreciate your tone.

Errr, I don't know, really, I've been nothing but appreciative of your help, and reading myself again I don't see really what sentence you thought was rude or unpolite. If so I apologize, but please understand I don't speak English much, and maybe I chose my words poorly or used sentences the wrong way ? I don't know really, I am very surprised and disappointed my sentences are understood the wrong way.
I think maybe this is because on another topic I've created, my explanations didn't seem clear, and people kept asking me "is the problem solved or not", so here I wanted to make clear the problem wasn't solved and the change of code din't improve the situation. Really that is all, and again, apologies.

ANYWAY :
Just in case you still read this : you were right about the "output" of albums, I set it differently and now there are albums.
Problem is, it seems like I'm back to step one : I've got albums and "sub-albums" (I understand from your explanations this is the same) appearing next to each other.
See it : http://www.laurent-photo.com/main.php (second "NEWS" frame is mediablock's).

Is there a part of code from mediablock that can be changed to achieve my first goal ?

Thank you.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-10-25 22:54

the best thing about mediaBlock is you can specify the album
actually I think in dynamic mode its albumId=xxx

{php}@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_albumId=7&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=1&shuffle=1&useThumb=1');{php}

you can put 4 of these side-by-side for 4 different albums.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Mon, 2010-10-25 23:13

Thank you.

I have to admit I don't understand.
You must think I'm an idiot by now...

I think I understand this line of code you show here allows to display one album, actually the one I want. Right ?

If I am right, how come whatever number I type after "albumId=" displays nothing (displays the word "Array" on a blank page) ? I've tried various numbers or combinations of numbers, trying to understand how it works, none of them shows any album. Only works with "7".

Considering I manage to sort this out... If I understood previous statements right, how do I set mediablock to NOT display "main albums", but only "sub albums" as is my wish ?

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Mon, 2010-10-25 23:27

I managed to use my Item_ID codes, I think I got it (for the first part of my question).
What I don't understand is how on Earth you managed to get this result with "albumID=7" !! My album Ids ("ItemID" actually) are 4 figures numbers (ex : 2423, 1645...).

This being said, it's a step in the right direction.

But I still can't get it. I mean, the whole "album ID" thing, and how it works with the "UpdatesAlbum".

I tried MANY things, and I get the exact same result with this code, with no mention of "UpdatesAlbum" :

or this code, similar to yours, with "UpdatesAlbum" activated :

Right now I have 2 options, it seems :
- if I set "limit = 3" (with album_ID=7) I get the list of my 3 last updated albums, including main and sub albums, which is not good.
- if I select the albums I want to display and have them all on one line, I know how I can select and display one album, BUT I don't know how I can do that automatically, detecting they are new. I don't want to edit the album.tpl file every time I put an update online...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 00:09

albumID=7 is the root album.
every item in gallery be it a photo, movie, album, user, module... has an ID.
You need to use the albumId of the album you want to display your sub-albums for.
You can usually see the id in the url to your album, or in the edit url.
for example 1506 is the id for your Crowbar album http://www.laurent-photo.com/main.php?g2_itemId=1506
1717 is the id for Dark Funeral http://www.laurent-photo.com/main.php?g2_itemId=1717

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 07:37

Hello,

OK, I get it. AlbumID=7 is a figure I coudn't find (I still don't understand how it is the root album, as this one has no number as far as I can see, but it's not an issue, I understand that).

So thank you, now I understand how it works and how I can come up with the albums I want to see, one by one.

What I still don't understand is how I can use Mediablock to "generate" itself the numbers of the last albums updated, without having "root" albums (parents) displayed, which was my very fist question.

Of course I can't edit the album.tpl file every time I upload a new album...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 12:43

how about this...

{php}
$albumId = isset($_REQUEST['g2_itemId'])?$_REQUEST['g2_itemId']:7;
@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_albumId='.$albumId.'&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=1&shuffle=1&useThumb=1');
{php}

This way if you are in the root album, it will display updated albums that are children of the root album.
But if you are in your Crowbar album it would automatically display updated albums that are children of that album only.

The updates album module is recursive so it looks deep into your album structure.

Or maybe we can adjust mediaBlock to show latest photos, but the photos link to their parent album instead of the photo itself.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 14:29

Here is an example of displaying random items but linking to the parent album instead of the item itself:
http://www.flashyourweb.com/gallery2/mediaBlock5.php?g2_itemId=32&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=6&useThumb=1&column=3&rss=1&linkToParent=1

notice I added &linkToParent=1 to the query to use this functionality you'll have to adjust one function:
change function getLink to:

function getLink($item) {
    global $gallery;
    $id = (isset($_REQUEST['linkToParent']) && $_REQUEST['linkToParent'] == 1)?$item->getParentId():$item->getId();
    $urlGenerator = &$gallery->getUrlGenerator();
    $link = $urlGenerator->generateUrl(array('view'=>'core.ShowItem', 'itemId'=>$id), array('forceFullUrl'=>true, 'forceSessionId'=>false));
    return $link;
}

BTW, mediaBlock5.php is my latest experimental which uses no html tables in favor for html5/CSS3 tables and box-shadow for the dropshadow.
In case you're interested in the newer version.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 15:23

Thank you.
I'm currently at work and will try this out when back at home in a few hours.

2 questions already :
- as I told before, I am lame at code and all... Where can I find this "function getlink" ? Is it in mediablock.php file ?
- As for mediablock5, is your code working with mediablock "regular version", or do you suggest I use mediablock5 ? if so, where can I download it from ? What you mention as changes between regular version and version 5 doesn't affect the way I use it (I think) so I think it may be the same. Except if your function change up here only applies on mediablock5.

Again, thank you. Will keep you posted, but it seems promising...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 15:26
 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 20:38

I can't make it work, man... :-(

Let's sum up what I did :

- changed the GetLink function like you said

- added this part to my album.tpl file :

Quote:
{php}
$albumId = isset($_REQUEST['g2_itemId'])?$_REQUEST['g2_itemId']:7;
@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_albumId='.$albumId.'&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&shuffle=0&useThumb=1&linkToParent=1');
{/php}

And there is no change.

I added the "linkToParent=1" part.

Actually, there might be something wrong in the part of code I quoted right here, cause that didn't change a thing ==> the "$albumId = isset($_REQUEST['g2_itemId'])?$_REQUEST['g2_itemId']:7;" part of the code didn't change a thing, it appears right as it was before.
I probably missed something ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 21:11

when you add/change any template file in gallery, you must clear the template cache in Gallery Admin -> Maintenance
FAQ: How can I clear cached data?

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 21:21

Yeah, I know that, I do that once in a while (and I just did right now), with no change.

Actually, as I'm still working on this website, I disabled the "cache" option, so it's slower, but I shouldn't have to clear the cache...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 21:33
Quote:
but I shouldn't have to clear the cache...

still do, different kind of caching.

Quote:
with no change.

I just cannot believe that.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 21:43

I bet you did not change Gallery Admin -> Dynamic Album back to data items only.
in this scenario we were going to display latest photos, but link to parent album.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 21:44

I don't know, maybe I missed something...

Again, what I did, considering your posts today :

- changed the Getlink function, I pasted exactly what you wrote instead of what was written in that function, as I don't know a thing about PHP. Uploaded new version of mediablock.php

- wrote the part of code I quoted in my previous post. I changed that a little from what you suggested, as it seemed you forgot a "/" at the end in "{/php}" and only changed a few options in the display (limit=3, that kind of things...). Uploaded new version of album.tpl.

- cleared the cache. Again (just did right now). I did it again, twice since you asked me, but as I told you, I actually disabled the template cache from the "performance" page in Gallery admin.

I don't know what I can tell you...

I can send you my admin password and/or FTP codes through personnal messaging if you want ?...

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 21:52
suprsidr wrote:
I bet you did not change Gallery Admin -> Dynamic Album back to data items only.
in this scenario we were going to display latest photos, but link to parent album.

You were right, I didn't even know I had to do that (told you I was an idiot).

I changed it and now I have the 3 latest uploaded pictures appearing.

Good thing is : you are right, they link to parent album. This is good.

Bad thing is : I have all the latest uploaded pictures, so they all link to the same album...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 22:13

Well, the original way should have worked fine.
Show the 3 latest updated albums, change dynamic album admin back to albums only, limit the return to 3 and use:
@readfile('http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&column=3&useThumb=1');

there should be no problem there, it will show the 3 latest updated albums, not their parents(unless you want to link to the parent &linkToParent=1)

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Tue, 2010-10-26 22:30

Well, I don't know what to say...

It works like "I don't want it to" ==> there are the 3 latest uploaded albums, but the last ones appear both for the parent album and the child album...

Let me clarify what I just did :

I changed the whole code here :

Quote:
{php}
$albumId = isset($_REQUEST['g2_itemId'])?$_REQUEST['g2_itemId']:7;
@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_albumId='.$albumId.'&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&shuffle=0&useThumb=1&linkToParent=1');
{/php}

With this simple code here :

Quote:
{php}
@readfile('http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&useThumb=1');
{/php}

I have let the mediablock as it was (hence after I changed the Getlink function).

JUST WANT TO MAKE SURE OF SOMETHING :
Was I clear in my very fist post here, when I explained that even though both the parent AND child albums were updated, I only wanted the child to display ? Cause the parent is just "holder" for the child.
So I know they are both really the latest updated albums, this is true, but I just don't EVER want the parent album to appear...

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Wed, 2010-10-27 22:11

I'm kinda stuck here, would anybody have an idea to help me ?

I am helpless with coding...

I would imagine there is a way to tell Gallery to display album thumbnails of all updated albums UNLESS they contain other albums ? Or ONLY IF another album contains it ?

I understand from suprsidr that there are no such thing as "container" in albums... But surely there is some kind of link parent-child one could use as a test to know if an album's thumbnail can bes displayed or not ?

What I could do also would be to name my sub-albums a special way if it can help ? (for instance : all sub-albums could start with "-")

Or maybe I could use the description field only for sub-albums and we could test this ?

Really I'm open to any suggestion or ideas to achieve that goal...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2010-10-27 23:02

I actually have two other related functions:

function hasChildAlbums($id){
    list($ret, $tree) = GalleryCoreApi::fetchAlbumTree($id, null, null);
    if ($ret) {
        return null;
    }
    return count(array_keys($tree));
}

function hasDataItems($item){
    list($ret, $itemCount) = GalleryCoreApi::fetchChildDataItemIds($item);
    if ($ret || !isset($itemCount[$item->getId()])){
        return null;
    }
    return $itemCount[$item->getId()];
}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Wed, 2010-10-27 23:11

Hi Suprsidr, thanx for sticking here and trying to help me :-)

Please remember I barely know what PHP is... I don't even know what those functions are, how I use them, what I need to do with it...

I understand it might be a pain to tell me everything I need to do step by step... I'm willing and trying to learn, though, and already learnt a lot, with your help...

Thanx for giving me a bit more explanations or instructions...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2010-10-27 23:26

Well, if you inserted those function into mediaBlock.php to make them available for us to use....
then we could use a conditional statement like the one we commented out before:

                //if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                //}
                if (!(hasChildAlbums($childItem->getId())) {
                    $display .= getDisplay($childItem);
                }

so if it does not (!)hasChildAlbums then it will display.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Wed, 2010-10-27 23:40

Difficult for me...

I did paste those 2 functions at the end of mediablock.php

But that piece of code in your latest code, I don't understand how it's supposed to be used... Of course I've tried different things, and it ends up with PHP error messages on my website... So I'm doing wrong.

What is the next step exactly after I added those 2 functions in mediablock.php ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-10-28 00:19

in function getDynamicChildIds line~272 change from:

                //if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                //}

to:

                if (!(hasChildAlbums($childItem->getId()))) {
                    $display .= getDisplay($childItem);
                }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-10-28 00:21
 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Thu, 2010-10-28 18:16

Thank you sprsidr.

I updated mediablock as you said.

Which way should I "call" it from album.tpl ? I mean, which url ?

I've tried this :

Quote:
{php}
$albumId = isset($_REQUEST['g2_itemId'])?$_REQUEST['g2_itemId']:7;
@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_albumId='.$albumId.'&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&shuffle=0&useThumb=1&linkToParent=1');
{/php}

and this:

Quote:
{php}
@readfile('http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&useThumb=1');
{/php}

and even this :

Quote:
{php}
@readfile('http://www.laurent-photo.com/mediaBlock.php?g2_itemId=7&mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&useThumb=1&column=3&showTitle=1');
{/php}

None of those work.

And should I do anything else ?

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Fri, 2010-10-29 18:16

Sorry for "bumping" this post, but I feel the answer might be near ?...

Feeling hopeful all of a sudden...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-10-29 22:16
 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Fri, 2010-10-29 22:32

Aaaargh, this is SOOOO bloody close !!!

Check it out, I changed the parameters of the url with mediablock to fit what I wanted :
http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&useThumb=1&showTitle=1

Problem is : both limit and column are set to 3, BUT of course, you managed to NOT display album #2 (which is a parent album, so it's great), problem is, album #4 won't complete the list of 3 : I have only 2 albums displayed !!

Maybe there might be a way to "count" how many albums are displayed, til it reaches 3 then stops displaying the next ones ????

This is a huge step forward, you rock suprsidr.

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sun, 2010-10-31 14:25

Hello,

Just so you know, even though it's not my main problem here, I have found a good use of mediablock and with your advices : as you can see here http://www.laurent-photo.com/main.php the "RANDOM" frame uses mediablock instead of regular gallery block, cause I find a very good use of your "linktoparent" function ==> with lighbox on, when I linked to the image directly, there was no lightbox. Now, it links to the regular album, and lightbox can be used.
So thank you, again.

Can't see where I'm going with my main problem above though.
If you think there is no solution, I guess I'll embed a news script in there which I'll update everytime, I don't know... Let me know if you think it's a dead cause or if you think there might be a solution...

I myself thought about it, maybe the key solution is in the "updated album's definition" ? I mean, there must be an information somewhere that says which album has been updated when. This information being used then with the "Updatedalbum" function of gallery. Maybe there is a way to have some albums not counted as updated ?
Hey I know it sounds silly maybe, I am looking for any ideas to make it work...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-10-31 19:07

so your dynamic album admin is set to display albums only?

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sun, 2010-10-31 19:52

Yes it is. Should it be otherwise ?
I have to admit I never really understood this setting...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-10-31 20:40

I may have just thought of a possible fix.
So your albums are all arranged like this:

Root Album
-Album1
--SubAlbum1
--SubAlbum2
-Album2
--SubAlbum1
--SubAlbum2
-Album3
--SubAlbum1
--SubAlbum2

So we don't want to display any album directly under Root Album.
So just add this to our condition:

    if (!hasChildAlbums($childItem->getId()) && $childItem->getParentId() != 7) {
        $display .= getDisplay($childItem);
    }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sun, 2010-10-31 22:04

Step by step I have the feeling it keeps closer :-) All hope is not gone !

Now the getDynamicChildIds function looks like this at the end (line 268) :

Quote:
foreach ($childItems as $childItem) {
/* We need to check the disabledFlag for each in dynamic mode */
$disabled = getDisabledFlag($childItem->getId());
if (!$disabled) {
if (!(hasChildAlbums($childItem->getId()))) {
$display .= getDisplay($childItem);
}
if (!hasChildAlbums($childItem->getId()) && $childItem->getParentId() != 7) {
$display .= getDisplay($childItem);
}
}
}

And when I click above link (http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&useThumb=1&showTitle=1) I have the accurate "level" of albums (i.e. none album directly under root album, the condition you defined works), problem is : when album1 AND subalbum1 have been updated, now subalbum1 appears twice (one time for itself, and the second one instead of its parent album, "album1"). See by yourself, you will understand.

I don't know which condition could change this now.

Maybe not displaying 2 times the same album ?
Or if an album is directly under root is updated, then NOT display anything instead of its child ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-10-31 23:05

Honestly, I tired of this specialized issue 40 posts ago.
Do you only have the one updated album? even when I add shuffle it still shows only this one album.
http://www.laurent-photo.com/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=3&column=3&useThumb=1&showTitle=1&shuffle=1
You should be returning the default 24 items in dynamic albums admin.

My last bit of input:

$alreadyDisplayed = array();
foreach ($childItems as $childItem) {
    /* We need to check the disabledFlag for each in dynamic mode */
    $disabled = getDisabledFlag($childItem->getId());
    if (!$disabled) {
        if (!(hasChildAlbums($childItem->getId()))) {
            $display .= getDisplay($childItem);
        }
        if (!hasChildAlbums($childItem->getId()) && $childItem->getParentId() != 7 && !in_array($childItem->getId(), $alreadyDisplayed)) {
            $display .= getDisplay($childItem);
            $alreadyDisplayed[] = $childItem->getId();
        }
    }
}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
MFNO

Joined: 2007-12-13
Posts: 63
Posted: Sun, 2010-10-31 23:45

Hello suprsidr and thank you

In your url, you added "shuffle" parameter to a url that calls "updatesAlbum", that doesn't seem to go well together in my opinion : there is no such thing as "shuffle" in a list of last updated albums (in your website, "shuffle" parameter is described as "Randomize results").
Also, the limit is set at 3 (again, see the parameter in the url "limit=3"), so there is no way it could display more than 3 albums.

So the url works fine through mediablock.

I tried your new attempt and it doesn't work.

I appreciate all your help and am grateful you spent time trying.

I am sorry you got tired though. You could/should have stopped earlier if you were not willing to. This is a big issue for me, as I am just not able to display my latest additions to my gallery. This "albumupdates" option of Gallery was one of the few things that made me choose Gallery over many other galleries softwares.

I agree that post is getting complicated, and it has become real difficult for anybody else to try to read / understand / help. So if you don't feel you can help any more using mediablock, I will probably create a new, updated, cleaner post, asking for help from other contributers or experts.

Again, I thank you for your time and help, even though that didn't solve my problem.