How to Add Random Images to My Gallery Home Page?

micronicos

Joined: 2005-09-20
Posts: 12
Posted: Tue, 2011-03-01 07:29

I have a simple gallery home page with only three thumbnails PEOPLE / PLACES / COLLECTIONS.

It looks therefore quite empty & I want to have say 6 random images showing in two rows as thumbnails below the three root album thumbnails. When I add using 'ImageBlock' in Album Settings I can only get random images at the side, not in below the root album thumbnails.

I've searched the forums & have only found http://gallery.menalto.com/node/80554 which I'm not sure how to implement, code as below?

I'm not sure exactly which version of Gallery I'm using, V2.3 it says on icon, how do I get all the info (Gallery, PHP, MySQL etc) needed?

Would this [modifed] code below, from the post above, work for me & where exactly do I put it in album.tpl?

Quote:
{if empty($theme.parents)}
root album only
{if $theme.pageType != 'admin'}
stuff on root album only and not a admin page
<table width="100%" border="0">
<tr>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
</tr>
<tr>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
<td><div align="center">{g->block type="imageblock.ImageBlock" blocks="randomImage" maxSize="150" showDate=0 showOwner=0 showViews=0 showTitle=0 showHeading=0 useDefaults=0 repeatBlock=2}</div></td>
</tr>
</table>
{/if}
{/if}

Thank you in advance.

Best Regards,
Nico Morrison
London UK

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2011-03-01 12:03
 
micronicos

Joined: 2005-09-20
Posts: 12
Posted: Wed, 2011-03-02 05:21

Thanks a lot "Flashyourweb" - I will play with it & it looks ideal as an external random show.

Which was not what I wanted though; I need to show a random set of images inside the Gallery Home page itself, under the three main category thumbs, not in the sidebar.

I'm nervous about inserting PHP code into album.tpl but guess I'll just go ahead & see, reverting if problems.

Nico M
London UK

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-03-02 14:10

php in smarty templates would be like:

{php}@readfile('http://www.flashyourweb.com/gallery2/mediaBlock.php?g2_itemId=32&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=11&useThumb=1&column=4&rss=1');{/php}

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

 
micronicos

Joined: 2005-09-20
Posts: 12
Posted: Thu, 2011-03-03 04:43

@suprsidr thanks.

I played with your nice mediaBlock for several hours but couldn't get it to work for me, I know it's me but time started to press.

Then decided to hack /local/album.tpl instead & had great success, very pleased with the random images on my home Gallery page, works a treat & looks very good.

Regarding mediaBlock , I was able to call the mediaBlock page without errors showing but whacking the pull-code into a standard html page resulted in nothing happening; fopen is ON, but I just couldn't debug something with no error messages, tried several cfgs as per your examples.

I did wonder if my problem is that my /g2data/ directory is above the document root (recommended). I used ../g2data in the mediaBlock call, no errors but nothing happens in the html page.

HTML ROOT: ***/site/html/
GAL DATA: ***/site/g2data/

If that makes sense,
Nico M
London UK

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-03-03 12:12

php does not get executed in .html of .htm unless you add that type...

-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, 2011-03-03 14:13

This is what I added to my album.tpl here.

{php}@readfile("http://html5.suprsidr.com/media/mediaBlock.php?g2_itemId=".$this->_tpl_vars['theme']['item']['id']."&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=3&useThumb=1&column=3");{/php}

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