Album Thumbnail instead Album Title on album page
|
perica6892
Joined: 2009-08-02
Posts: 12 |
Posted: Sun, 2009-08-02 18:08
|
|
Hello, I've installed Gallery2 a few days ago and I was instantly impressed with it's features. I've started with Matrix theme and customized it almost to the point how I want it. You can check the gallery here http://www.parasole.rs/gallery/main.php The only thing left to do is to make Album Thumbnail as is on the main page to be displayed instead of I've searched the forums and couldn't find the answer. Can someone point me to the topic which cover this, if it exists on the forums, or at least give me Thank you! |
|

Posts: 16503
Can you post a screenshot or mockup of what you're looking for. I'm not sure what you want changed.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 12
Hi nivekiam, thank you for reply.
If you visit the url I posted in first message, you will see main (root) gallery.
Click any of the galleries, for example "Audi", and you can see name of the gallery
"Audi" centered above images.
I would like instead of that to be album thumbnail, which in this case is Audi logo,
as is in the root gallery.
Here is the picture of what I want to achieve, logo in red square in first image should
be in place of red square in second picture.
Posts: 6136
We don't have access to anymore info about the parent besides its id.
You'd have to add the extra parameter to theme.inc.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 12
Hmm, if ID of the parent is known, how can I get it's thumbnail based on that?
I see it's possible to get parent's name, so I suppose this should be possible too.
Posts: 6136
Hmm, sorry my bad, it would be $theme.item, not $theme.parent - but the thumbnail is still not available(at least in carbon).
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 16503
And I don't think Carbon is that different from Matrix. If you put Gallery into Debug Mode, you can see a Smarty Debug popup window that will show you everything that's currently available on any page.
FAQ: How to set/use Gallery in debug mode?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 12
Thanks for you replies.
I found that I could use GalleryCoreApi::fetchThumbnailsByItemIds($itemId)
but I'm a bit off from there.
Where should I put that line in order to retrieve a thumbnail based on album ID?
Posts: 6136
in theme.inc function showAlbumPage after $theme =& $template->getVariableByReference('theme');
add:
list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($item->getId())); if (!$ret && ! empty($thumbnail)) { $theme['item']['thumbnail'] = $urlGenerator->generateUrl(array('view'=>'core.DownloadItem', 'itemId'=>$thumbnail[$item->getId()]->getId(), 'serialNumber'=>$thumbnail[$item->getId()]->getSerialNumber()), array('forceFullUrl'=>true, 'forceSessionId'=>true, 'htmlEntities'=>true)); } if ($ret) { return array($ret, null); }this will make $theme.item.thumbnail available in album.tpl
untested.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 12
Not working by just copying and pasting.
After adding the code to theme.inc and <center>{$theme.item.thumbnail}</center> into album.tpl
I get an HTML 500 internal server error when I try to load the page...
Am I missing something here?
As a side note, I don't know if this matters, album thumbnail is not an image from the album, I added it as Custom album thumbnail.
Thank you very much for your time suprsidr
Posts: 12
I tried this
list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($item->getId()));
$theme['item']['thumbnail'] = $thumbnail[$item->getId()]->getId();
if ($ret) {
return array($ret, null);
}
And it's returning 49 when calling $theme.item.thumbnail
But, when looking in address bar of my browser I see
http://www.parasole.rs/gallery/main.php?g2_itemId=29
Shouldn't it show 29?
Posts: 12
My bad, 49 is actually id of the thumbnail
Now I'm getting somewhere
Then, my best guess, the error is somewhere in this line
$theme['item']['thumbnail'] = $urlGenerator->generateUrl(array('view'=>'core.DownloadItem', 'itemId'=>$thumbnail[$item->getId()]->getId(), 'serialNumber'=>$thumbnail[$item->getId()]->getSerialNumber()), array('forceFullUrl'=>true, 'forceSessionId'=>true, 'htmlEntities'=>true));
Posts: 6136
The thumb's id is different then the actual album's id.
I'll actually test it out on mysite.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 6136
I'm generating the actual thumbnail url so in the template you would use <img src="{$theme['item']['thumbnail']}"/>
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 12
When I try to right click the thumbnail and copy/paste it's address
http://www.parasole.rs/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=49&g2_serialNumber=5
it takes me to the right picture.
I don't know what is causing the error here.
Posts: 12
Not working, I can't even get the url to show up as a string...
Again, this is what I have in theme.inc
And now I'm calling it from album.tpl with
Posts: 6136
Sorry, I was getting a little sloppy:
global $gallery; $urlGenerator = &$gallery->getUrlGenerator(); $itemId = $item->getId(); list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($itemId)); if (!$ret && ! empty($thumbnail)) { $theme['item']['thumbnail'] = $urlGenerator->generateUrl(array('view'=>'core.DownloadItem', 'itemId'=>$thumbnail[$itemId]->getId(), 'serialNumber'=>$thumbnail[$itemId]->getSerialNumber()), array('forceFullUrl'=>true, 'forceSessionId'=>true, 'htmlEntities'=>true)); } if ($ret) { return array($ret, null); }and then in album.tpl
<img src="{$theme.item.thumbnail}"/>
works for me.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 12
I thought it had something to do with not defining what $urlGenerator was, but I didn't want to pretend smart
I managed to display the thumbnail by simple string concatenation
$theme['item']['thumbnail'] = 'http://www.parasole.rs/gallery/main.php?g2_view=core.DownloadItem&g2_itemId='.$thumbnail[$item->getId()]->getId().'&g2_serialNumber='.$thumbnail[$item->getId()]->getSerialNumber();But your approach is universal, now I'll test it.
Posts: 12
And it works perfectly.
Thanks a bunch suprsidr
Posts: 12
As a thank you, I'm writing the tutorial how to do this in case other users need this too.
NOTE: This tutorial is based on default Matrix theme and if you are using another theme things might be slightly different, but in general this should work for all the themes, only line numbers should be different.
HOW TO DISPLAY ALBUM THUMBNAIL INSTEAD OF ALBUM TITLE
By default, G2 is set to display album name on top of the page when browsing through the galleries.
If you want to change this behaviour, and display album's thumbnail instead, this is what you should do:
- Open the file theme.inc located under /[YOUR GALLERY2 INSTALL DIR]/THEMES/[YOUR THEME]/
- Find the code
$theme =& $template->getVariableByReference('theme');on approx. line 71
- After that line paste the following code
/*Custom code by suprsidr to enable album thumbnail*/ global $gallery; $urlGenerator = &$gallery->getUrlGenerator(); $itemId = $item->getId(); list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($itemId)); if (!$ret && !empty($thumbnail)) { $theme['item']['thumbnail'] = $urlGenerator->generateUrl(array('view'=>'core.DownloadItem', 'itemId'=>$thumbnail[$itemId]->getId(), 'serialNumber'=>$thumbnail[$itemId]->getSerialNumber()), array('forceFullUrl'=>true, 'forceSessionId'=>true, 'htmlEntities'=>true)); } if ($ret) { return array($ret, null); } /*end of custom code*/- Save theme.inc
- Open up the album.tpl located under /[YOUR GALLERY2 INSTALL DIR]/THEMES/[YOUR THEME]/TEMPLATES/
- Find this line of code
<h2> <center>{$theme.item.title|markup}</center> </h2>- Replace this line with the following code
<img src="{$theme.item.thumbnail}"/>- Save album.tpl
- That's it. now you should see album's thumbnail instead of it's name showing up as the gallery title.
Posts: 1
To perica6892, thanks
After your post established Galery2 and was pleasantly surprised by its features
Best regards