imagablock to show random image from current album

wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Wed, 2012-04-04 10:09

I am a silent observer of gallery2 forum since 2008 and thanks all supporter for providing needed info :)

I ran in to trouble and seek expert advice

I have imagablock under each photo example can be seen at
http://www.wallpaperhungama.com/Celebrities/Hollywood/Angelina_Jolie/Angelina_Jolie_a001.jpg.html

Now i want imageblock to show random image from Album "Angelina_Jolie"

i dont know what itemId i need to specify

<div class="g2imageblock">
{g->block type="imageblock.ImageBlock" blocks="randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage" show="none"}
</div>

please help experts :)

Last Run Details:

Gallery URL = http://www.wallpaperhungama.com/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.17 cgi
Webserver = Apache
Database = mysqlt 5.0.95-community, lock.system=flock
Toolkits = ArchiveUpload, Gd, Getid3, LinkItemToolkit, SquareThumb, Thumbnail, ImageMagick
Acceleration = none, none
Operating system = Linux accord.host-care.com 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 04:16:51 EST 2012 x86_64
Default theme = matrixad
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Rows in GalleryAccessMap table = 127
Rows in GalleryAccessSubscriberMap table = 48816
Rows in GalleryUser table = 116
Rows in GalleryItem table = 48798
Rows in GalleryAlbumItem table = 397
Rows in GalleryCacheMap table = 0

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2012-04-04 12:38

would be easier to do with mediaBlock:

{if $theme.pageType == 'album'}
  {php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId={$theme.item.id}&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10{/php}
{else if $theme.pageType == 'photo'}
  {php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId={$theme.parent.id}&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10{/php}
{/if}

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

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Wed, 2012-04-04 12:51

Error loading initial item:Error (ERROR_MISSING_OBJECT) : Missing object for 0

in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 2054 (GalleryCoreApi::error)
in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 98 (GalleryStorageExtras::_identifyEntities)
in modules/core/classes/GalleryStorage.class at line 313 (GalleryStorageExtras::loadEntities)
in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 71 (GalleryStorage::loadEntities)
in modules/core/classes/GalleryCoreApi.class at line 2361 (GalleryEntityHelper_simple::loadEntitiesById)
in mediaBlock.php at line 995 (GalleryCoreApi::loadEntitiesById)
in mediaBlock.php at line 1079

Array

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Wed, 2012-04-04 12:56

m currently using
<div class="g2imageblock">
{g->block type="imageblock.ImageBlock" blocks="randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage|randomImage" show="none" itemId=$theme.parent.id}
</div>

but will love to switch to mediablock

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Wed, 2012-04-04 13:14

also would like to show the album name with simple text

More Images from the Album "Album Name"
{if $theme.pageType == 'album'}
{php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId={$theme.item.id}&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10{/php}
{else if $theme.pageType == 'photo'}
{php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId={$theme.parent.id}&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10{/php}
{/if}

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2012-04-04 13:20

try:

{if $theme.pageType == 'album'}
  {php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId='.$this->_tpl_vars['theme']['item']['id'].'&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10');{/php}
{else if $theme.pageType == 'photo'}
  {php}@readfile('http://www.wallpaperhungama.com/mediaBlock.php?g2_itemId='.$this->_tpl_vars['theme']['parent']['id'].'&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10');{/php}
{/if}

and you must have the dynamic albums module installed/active

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

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2012-04-04 18:25

Just tested this code, forgot to close those statements.
This works:

      <center>
        {if $theme.pageType == 'album'}
        <h3>Other items from the {$theme.item.title} album</h3>
          {php}@readfile('http://testr.suprsidr.com/mediaBlock.php?g2_itemId='.$this->_tpl_vars['theme']['item']['id'].'&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10&useMicro=90');{/php}
        {else if $theme.pageType == 'photo'}
        <h3>Other items from the {$theme.parent.title} album</h3>
          {php}@readfile('http://testr.suprsidr.com/mediaBlock.php?g2_itemId='.$this->_tpl_vars['theme']['parent']['id'].'&mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=10&useThumb=1&column=10&useMicro=90');{/php}
        {/if}
      </center>

using useMicro to control the size for the space example

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

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Thu, 2012-04-05 06:21

worked like a charm...thanks will consider a small donation

a small help

how to embed php code in blogger sidebar

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Thu, 2012-04-05 15:21

giving some errors om dynamic albums pages

http://www.wallpaperhungama.com/main.php?g2_view=dynamicalbum.UpdatesAlbum

Other items from the Recent Updates album
Error loading initial item:Error (ERROR_BAD_PARAMETER)

in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 39 (GalleryCoreApi::error)
in modules/core/classes/GalleryCoreApi.class at line 2361 (GalleryEntityHelper_simple::loadEntitiesById)
in mediaBlock.php at line 995 (GalleryCoreApi::loadEntitiesById)
in mediaBlock.php at line 1079

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-05 15:37

you'd need to check for dynamic albums as they have no id.
from:

{if $theme.pageType == 'album'}

to:

{if $theme.pageType == 'album' && $theme.item.entityType != 'GalleryDynamicAlbum'}

you could also have a default id for dynamic albums

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

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Thu, 2012-04-05 17:42

actually i m not using if then and simply added ur code in album.tpl so adding GalleryDynamicAlbum wont make any difference

my question is where should i put if then else statement in theme.tpl to have the random images from parent album below image as it is now shown

  <body class="gallery">
    <div {g->mainDivAttributes}>
      {*
       * Some module views (eg slideshow) want the full screen.  So for those, we don't draw
       * a header, footer, navbar, etc.  Those views are responsible for drawing everything.
       *}
      {if $theme.useFullScreen}
	{include file="gallery:`$theme.moduleTemplate`" l10Domain=$theme.moduleL10Domain}
      {elseif $theme.pageType == 'progressbar'}
	<div id="gsHeader">
	  <td width="200"><a href="http://www.wallpaperhungama.com/"><img src="/images/galleryLogo_sm.gif" width="190" height="79" alt="WallpaperHungama" border="0"/></a></td>
	</div>
	{g->theme include="progressbar.tpl"}
      {else}

      <div id="gsHeader">
	
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200"><a href="http://www.wallpaperhungama.com/"><img src="/images/galleryLogo_sm.gif" width="200" height="89" alt="WallpaperHungama" border="0"/></a></td>
<td valign="bottom" id="header-bgimage"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75%" height="40">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td align="right">			<table cellpadding="0" cellspacing="0" class="moduletable">
<tr>
<td>
<ul id="mainlevel-nav">
<li><a href="http://feeds.feedburner.com/WallpaperHungama" class="mainlevel-nav" >RSS</a></li>
<li><a href="http://www.wallpaperhungama.com/sitemap/" class="mainlevel-nav" >Sitemap</a></li>
<li><a href="http://www.24Rocking.com/" class="mainlevel-nav" >24Rocking</a></li>
<li><a href="http://blog.wallpaperhungama.com/" class="mainlevel-nav" >Blog</a></li>
<li><a href="http://www.FunKruti.Com" class="mainlevel-nav" >FunKruti</a></li>
<li><a href="http://www.wallpaperhungama.com/imageblock.php" class="mainlevel-nav" >MediaBlock</a></li>
<li><a href="http://www.wallpaperhungama.com/main.php?g2_view=dynamicalbum.RandomAlbum" class="mainlevel-nav" >Random</a></li>
<li><a href="http://www.wallpaperhungama.com/main.php?g2_view=dynamicalbum.PopularAlbum" class="mainlevel-nav" >Most Viewed</a></li>
<li><a href="http://www.wallpaperhungama.com/main.php?g2_view=dynamicalbum.UpdatesAlbum" class="mainlevel-nav" >Recent Updates</a></li>
</ul>				</td>
</tr>
</table>
</td>
</tr>
</table></td>
<td width="13"><img src="/images/header_right_corner.png" width="13" height="79" alt="WallpaperHungama" /></td>
</tr>
</table>

      </div>


      <div id="gsNavBar" class="gcBorder1">
	<div class="gbSystemLinks">
	  {g->block type="core.SystemLinks"
		    order="core.SiteAdmin core.YourAccount core.Login core.Logout"
		    othersAt=4}
	</div>

	<div class="gbBreadCrumb">
	  {g->block type="core.BreadCrumb"}
	</div>
      </div>

      {* Include the appropriate content type for the page we want to draw. *}
      {if $theme.pageType == 'album'}
	{g->theme include="album.tpl"}
      {elseif $theme.pageType == 'photo'}
	{g->theme include="photo.tpl"}
      {elseif $theme.pageType == 'admin'}
	{g->theme include="admin.tpl"}
      {elseif $theme.pageType == 'module'}
	{g->theme include="module.tpl"}
      {/if}

      <div id="gsFooter">
	<div align="center">
	     {g->theme include="randomimages.tpl"}

   {g->theme include="mgid.tpl"}
		
<a href="http://www.WallpaperHungama.com/">WallpaperHungama</a> - THE Wallpaper Hub!<br>

 <div class="copyright">
      	<p class="assert">© 2008-2012 WallpaperHungama. The content is copyrighted and may not be reproduced on other websites.</p>
      	<p class="links"><a rel="nofollow" href="mailto:info@wallpaperhungama.com">Contact/Takedown Request</a>  | <a rel="nofollow" href="http://www.wallpaperhungama.com/disclaimer.php">Disclaimer</a> | <a href="http://www.wallpaperhungama.com/privacy.php">Privacy</a> | <a href="http://www.wallpaperhungama.com/sitemap/index.htm">Sitemap</a><a href="http://feeds.feedburner.com/WallpaperHungama">RSS</a></p>

      </div>
</div>
      </div>
      {/if}  {* end of full screen check *}
    </div>

    {*
     * Give Gallery a chance to output any cleanup code, like javascript that needs to be run
     * at the end of the <body> tag.  If you take this out, some code won't work properly.
     *}
    {g->trailer}

    {* Put any debugging output here, if debugging is enabled *}
    {g->debug}
  </body>
</html>
 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-05 22:08

I'd add it where you want it to appear.
just above <div id="gsFooter"> for what you're doing on your site.

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

 
wallpaperhungama

Joined: 2012-04-04
Posts: 20
Posted: Fri, 2012-04-06 08:59

in my site i have put random images above gsfooter

and want images from current album under photos which must be defined in photo.tpl