Joined: Mar 29, 2003 Posts: 1038 Location: Cambs,UK
Posted: Fri Mar 03, 2006 2:20 am Post subject: Re: [TESTING] Selectable Album Random Block
Dari if you don't have the time or are unable to help can you please let me know so I can sort it another way - many thanks _________________ "The only difference between me and a madman is that I'm not mad."
Joined: Mar 03, 2003 Posts: 6284 Location: Washington Township, NJ, USA
Posted: Fri Mar 03, 2006 7:32 am Post subject: Re: [TESTING] Selectable Album Random Block
slackbladder wrote: › Dari if you don't have the time or are unable to help can you please let me know so I can sort it another way - many thanks
actually, after hacking away at the selectable block file, i realized that since you want to hardcode in the values of albums, that the normal random block file is what you should use.
try:
PHP: › <?php
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Developed by Dariush Molavi at NukedGallery.net
* Version 2.0
* 13 December 2003
*/
if (eregi("block-NG-RandomPhoto_functions.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME, $Version_Num;
/*******************************************************************/
/* Full path to your Gallery, don't forget the trailing / */
/*******************************************************************/
$GALLERY_BASEDIR = "/home/httpd/phpnuke.nukedgallery.net/htdocs/modules/gallery/";
/*******************************************************************/
/* The module name of your Gallery, default is "gallery" */
/*******************************************************************/
$GALLERY_MODULENAME = "gallery";
/*******************************************************************/
/* Time, in seconds, to refresh random photo cache. Default is */
/* 86400 (check it daily) */
/*******************************************************************/
define(CACHE_EXPIRED, 10);
/*******************************************************************/
/* Full path to your albums directory, don't forget the trailing / */
/*******************************************************************/
define(ALBUM_DIRECTORY,"/home/httpd/phpnuke.nukedgallery.net/htdocs/albums/");
/*******************************************************************/
/* STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT */
/*******************************************************************/
define(CACHE_FILE, ALBUM_DIRECTORY."block-random.cache");
function createBlockContent($album,$index,$scale,$auto=0) {
global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;
if ($choose) {
$album = new Album();
$album->load($choose);
return $album;
} else {
return null;
}
}
?>
note that in the readcache function, you'll need the album name and the number of photos in the album (the randomizer uses the number of photos to determine how often to pull from that album). _________________
Joined: Mar 29, 2003 Posts: 1038 Location: Cambs,UK
Posted: Fri Mar 03, 2006 7:35 am Post subject: Re: [TESTING] Selectable Album Random Block
Hi Dari,
Does the 'hacked' block create / re-build the cache file (so new photo's when added to the album are also added to the cache i.e. the cache number increases)? _________________ "The only difference between me and a madman is that I'm not mad."
Joined: Mar 03, 2003 Posts: 6284 Location: Washington Township, NJ, USA
Posted: Fri Mar 03, 2006 7:39 am Post subject: Re: [TESTING] Selectable Album Random Block
no, this is a quick and dirty hack. it doesn't use a cache file at all, just an array that you populate with your albums by hand (i thought that's what you wanted)...however, updating the array with the proper values shouldn't be too hard... _________________
Joined: Mar 29, 2003 Posts: 1038 Location: Cambs,UK
Posted: Fri Mar 03, 2006 7:46 am Post subject: Re: [TESTING] Selectable Album Random Block
What I am after (and have it working just about using the selectable block) is:
From the block code I can select (hard code) an album from which the random block pulls an image from.
I currently use a different 'cache' file for each album (e.g. album1-random.cache, album2-random.cache)
I need for the code to rebuild each seperate cache, using it's hardcoded album images.
The reason all this is that I have built a site (music) that has sections dedicated to different artists, each artist has a section the gallery for his photos.
Posted: Sat Jun 17, 2006 2:17 am Post subject: Re: [TESTING] Selectable Album Random Block
I'm getting MySQL errors when attempting to use it with Gallery2.
[edit] If this is only for Gallery1, is there a way to eliminate certain albums from displaying in the random photo block in G2?? [/edit]
Thanks!
Errors received:
Code: › Warning: main(/home/.alonso/xxxx/the152.com/modules/gallery2/init.php): failed to open stream: No such file or directory in /home/.alonso/xxxx/the152.com/NG-RandomPhotoSelectTest_functions.php on line 61
Fatal error: main(): Failed opening required '/home/.alonso/xxxx/the152.com/modules/gallery2/init.php' (include_path='.:/usr/local/lib/php') in /home/.alonso/xxxx/the152.com/NG-RandomPhotoSelectTest_functions.php on line 61