Random + Last Updates block together at last!

J-Mann

Joined: 2003-03-21
Posts: 90
Posted: Thu, 2003-04-17 15:34

Ok, the random photo block is located here;
http://www.perfectcell.org/Random_Photo_Block.zip

The last updates block is here:
http://www.perfectcell.org/Last_Updates_Block.zip

(read the readme files)

You can view both blocks working together at http://www.perfectcell.org

To get these two to display at once, you have to make several changes to one of them (BUT NOT BOTH!). DO NOT MAKE THESE CHANGES UNLESS YOU INTEND TO USE BOTH BLOCKS AT ONCE!

This fix will also allow you to have one of them on the left side (AND include it with your gallery pages). This has not been tested, but the logic is there.

In the block you want to be your secondary (not as important), this is the block that could (possibly) go on the left side, make the following changes:

REMOVE this line completely: require($GALLERY_BASEDIR . "init.php");

Change all functions to a different name, simply adding a number to the end is the easiest, like so:
Change scanAlbums() to scanAlbums2()
Change saveCache() to saveCache2()
Change readCache() to readCache2()
etc...

Remember to change all instances of the function name as well (there should only be one instance for each function definition, and one for the function call, but they must be renamed as well... otherwise it will call on the function of the same name from the other block, and the two cache files are different, so it won't work).

Change ALL INSTANCES of CACHE_XXXXX to CACHE2_XXXXX

Change this line:
define(CACHE_FILE, $gallery->app->albumDir . "/block-random.cache");

to the complete PATH (not URL) of your album directory, like this:
define(CACHE2_FILE, $gallery->app->albumDir . "/home/perfec4/public_html/albums/last-updated.cache");

There you have it and there you are. No more fs_copy redeclare when you use both blocks at once :grin:

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Tue, 2003-04-22 01:00

I get an error on line 50 and I lose all content in the middle and have to delete the file to get it back.

Line 50 = if (fs_file_exists(CACHE2_FILE)) {

Any ideas?

 
J-Mann

Joined: 2003-03-21
Posts: 90
Posted: Tue, 2003-04-22 03:13

What's the error? Is it Warning: cannot redeclare function fs_file_exits()...........?

Or is it something else?

You might want to use the original latest updates block, without modification, to create the cache file. Then disable it, enable the random photo block, make mods to the latest updates block and upload it (overwriting the original).

I had to do that once, for some reason it didn't want to create the new cache file.

Also, check to make sure that you made ALL changes above. Use the search option of your text editor. If you've uploaded the file and later found more changes that you missed, you MUST delete the cache file and let it re-create it for you. Otherwise it may be writing in (and thus reading) the wrong information. Or it may be looking at the wrong cache file alltogether.

I'm not sure what else it coule be unless you tell me what the error is.

Good luck,

J-

 
dmolavi
dmolavi's picture

Joined: 2002-12-05
Posts: 573
Posted: Tue, 2003-04-22 12:34

why go through all the trouble of renaming?
just change require(blah blah blah "init.php") to require_once(blah blah blah "init.php")
all your problems are solved.

you're welcome.

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Tue, 2003-04-22 12:49
Quote:
why go through all the trouble of renaming?
just change require(blah blah blah "init.php") to require_once(blah blah blah "init.php")
all your problems are solved.

So don't delete that line at all as stated in the install readme?

I am not getting an error the entire body section just vanishes and all I am left with is the left blocks.

I'll try both methods! 2nd first as it sounds like the best. Thanks for the help guys! :wink:

Cheers

 
dmolavi
dmolavi's picture

Joined: 2002-12-05
Posts: 573
Posted: Tue, 2003-04-22 13:50

no line deletions, just the addition of the _once after require.
it works: http://www.yankeesinthesouth.org for a demo.

 
J-Mann

Joined: 2003-03-21
Posts: 90
Posted: Tue, 2003-04-22 16:18

You still have to rename the functions and the cache file. Those have nothing to do with the fs_error. Because the functions and the cache definitions are not the same for the 2 files, so they must be renamed or it will read from the wrong functions OR it may read from the wrong cache file. And since the two cache files contain different information, one of the blocks will not display properly.

I tried :razz:

The require_once will allow you to include it with your gallery content, and put blocks on the left, but to have them both working, you'll have to rename things. The link to yankeesinthesouth is irrelivant to his post.... he's trying to get both blocks to work together, and I don't see a latest updates block on that page.

 
gecko

Joined: 2003-04-18
Posts: 1
Posted: Thu, 2003-05-01 04:31

Its all good for me - thanks J-Mann

What would be really cool is the caption for the random image too