Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

Author Topic: Hide albums from latest and random  (Read 45357 times)

0 Members and 1 Guest are viewing this topic.

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Hide albums from latest and random
« on: November 29, 2005, 07:37:36 pm »

I'm using 1.4 and I'm very pleased with it but is it possible to block certain albums from being shown in the random and latest images tables?  :)
« Last Edit: December 29, 2005, 09:12:35 am by GauGau »
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #1 on: November 29, 2005, 08:56:41 pm »

This can be done with plugins if were a little creative.

Modify the array: $unwanted_albs=array(1,25,14); to suit.

1,25,14 were just some sample albums that I was using for testing.

I zipped up the plugin it's attached to this post, the relevant code is below.

It isn't real pretty string manipulation, I'm sure someone who knows regexs like the back of thier hand could do it better... I just didn't want to think that much.

Code: [Select]
$thisplugin->add_filter('plugin_block','remove_meta_albs');

function remove_meta_albs($matches) {
    global $META_ALBUM_SET;
    if (is_array($matches)) {
        switch ($matches[1]) {
            case 'random':
            case 'lastup':
                $unwanted_albs=array(1,25,14);
                if ($META_ALBUM_SET) {
                    $parts=explode('(',$META_ALBUM_SET);
                    $head=$parts[0];
                    $parts=explode(')',$parts[1]);
                    $albums=explode(',',$parts[0]);
                    $new_albums=array_diff($albums,$unwanted_albs);
                    $META_ALBUM_SET=$head.'('.implode(',',$new_albums).')';
                }
                break;
        }
    }
    return $matches;
}
« Last Edit: November 30, 2005, 01:31:07 am by donnoman »
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Hide albums from latest and random
« Reply #2 on: November 29, 2005, 09:02:18 pm »

Thanks, sounds nice, but how am I going to get this into coppermine? Do I just have to drop the files into the coppermine folder?
Logged

Nibbler

  • Guest
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Hide albums from latest and random
« Reply #4 on: November 29, 2005, 11:03:26 pm »

I have some problems, the plugin doesn't seem to exclude the images from the last uploaded or random table.
I've changed $unwanted_albs=array(1,25,14); to $unwanted_albs=array(9); since 9 is the number of my album
I want to exclude. Are there other things that have to be done?  :)
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #5 on: November 30, 2005, 12:52:14 am »

#1 Make sure you did "install" the plugin. (It should be listed under "Installed Plugins" not "Plugins Not installed"
#2 replace the code in codebase with this:
Code: [Select]
$thisplugin->add_filter('plugin_block','remove_meta_albs'); //index.php
$thisplugin->add_filter('post_breadcrumb','remove_meta_albs'); //thumbnails.php

function filter_meta_album() {
    global $META_ALBUM_SET;
    $unwanted_albs=array(1,25,14);
    if ($META_ALBUM_SET) {
        $parts=explode('(',$META_ALBUM_SET);
        $head=$parts[0];
        $parts=explode(')',$parts[1]);
        $albums=explode(',',$parts[0]);
        $new_albums=array_diff($albums,$unwanted_albs);
        $META_ALBUM_SET=$head.'('.implode(',',$new_albums).')';
    } else {
        $META_ALBUM_SET='AND aid NOT IN ('.implode(',',$unwanted_albs).')';
    }
}

function remove_meta_albs($matches) {
    if (is_array($matches)) {
        static $run_once;
        if (!$run_once) {
            filter_meta_album();
            $run_once=true;
        }
    } elseif (defined('THUMBNAILS_PHP')) {
        filter_meta_album();
    }
    return $matches;
}

It should now filter the meta_album_set for the last_updated etc when displayed with thumbnails.php, including as an admin.

updated the plugin download.
« Last Edit: December 01, 2005, 06:03:58 am by donnoman »
Logged

noworyz

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 76
    • eGriz.com
Re: Hide albums from latest and random
« Reply #6 on: November 30, 2005, 12:54:44 am »

Not trying to hijack the thread but I had it working before that last bit of code you just posted.  Should I change the code also?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #7 on: November 30, 2005, 12:57:42 am »

probably.

There are two major differences.

#1 the previous code did not filter those albums for the admin.
#2 the previous code did not filter the meta albums when you clicked on say "last uploaded". It only filtered the blocks that are shown on the index.php page based on what you had configured in the "content of the main page".
Logged

noworyz

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 76
    • eGriz.com
Re: Hide albums from latest and random
« Reply #8 on: November 30, 2005, 01:03:33 am »

I made the change and I see no difference.  Either way it seems to be doing what it is supposed to!  Thanks!
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Hide albums from latest and random
« Reply #9 on: November 30, 2005, 08:32:04 am »

It works, thanks alot donnoman.  :D
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Hide albums from latest and random
« Reply #10 on: November 30, 2005, 09:11:01 am »

Should this be moved to cpg1.4 plugin contributions then?
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Hide albums from latest and random
« Reply #11 on: November 30, 2005, 03:17:16 pm »

Should this be moved to cpg1.4 plugin contributions then?

I think yes... (sorry for posting in the wrong forum)  :)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Hide albums from latest and random
« Reply #12 on: November 30, 2005, 07:44:18 pm »

@NeoID: you're not to blame, you posted in the proper board. The question goes at donnoman.
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #13 on: December 01, 2005, 06:03:19 am »

#1 Theres a problem with getting the wrong images with the previous versions of the plugin when using relative position when it's passed to displayimage.
#2 displayimage lacks a plugin hook that makes it possible to filter its meta_albums without MODDING displayimage.php.
#3 I've included instructions for making a single line mod to displayimage.php. Look in "readme.htm" for details.
#4 Theres a link to the readme.htm in the plugin description that you see on pluginmgr.php
#5 This thread can be moved to the plugins subfolder, but I would suggest that only COMPLETE plugins be moved. Threads that contain ideas for plugins to solve common problems should be left in the forum that spawned them until a complete plugin is created.

EDIT: There is a newer version of this plugin see: http://cpg-contrib.org/board/index.php?board=31.0
« Last Edit: December 03, 2006, 01:33:00 am by donnoman »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Hide albums from latest and random
« Reply #14 on: December 01, 2005, 06:25:23 am »

#5 This thread can be moved to the plugins subfolder, but I would suggest that only COMPLETE plugins be moved. Threads that contain ideas for plugins to solve common problems should be left in the forum that spawned them until a complete plugin is created.
I agree, that's why I asked. I should have been clearer: is the plugin stable enough to be added to the plugin contributions folder, or does it need further testing?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #15 on: December 01, 2005, 06:28:40 am »

I'm happy with it now. We won't officially add a new plugin hook until 1.5 so it will have to stay this way for the time being.
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Hide albums from latest and random
« Reply #16 on: December 29, 2005, 05:47:40 am »

#3 I've included instructions for making a single line mod to displayimage.php. Look in "readme.htm" for details.
No wonder I couldn't find the string anywhere in either cpg forums. :D I forgot why I added the hook.

Would it be an issue to include the hook in the CVS version of displayimage.php?

CPGPluginAPI::filter('displayimage_init',null);
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Hide albums from latest and random
« Reply #17 on: December 29, 2005, 10:23:51 pm »

I'm happy with it now. We won't officially add a new plugin hook until 1.5 so it will have to stay this way for the time being.

The plugin hides the pictures from the specified albums, but there is one serious bug.
If I upload an image to an excluded album and then click on a thumbnail from the "last added images" list, all pictures/links are out of sync. If I click the thumbnail, I see another picture and not the one I wanted to see...

Not only the "last added images" get's messed up, but also the "last comment"...practically all links between the automatic-generated
thumbnails and the actual file-preview is messed up...

Sorry, but I can't give you a url to show you the problem, but I hope you understand the problem...(my english is bad...) ^_^
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Hide albums from latest and random
« Reply #18 on: December 30, 2005, 02:12:24 am »

Would it be an issue to include the hook in the CVS version of displayimage.php?

CPGPluginAPI::filter('displayimage_init',null);

I'm of the opinion that hooks should only change between major revisions like 1.4 and 1.5.

I also think that we need to rethink the placement of some of the existing plugin hooks, and we need more consistency in naming.  The place to make these changes are in the devel version, not stable.
Logged

wolle

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Hide albums from latest and random
« Reply #19 on: February 04, 2006, 01:13:36 pm »

[...]
I zipped up the plugin it's attached to this post, the relevant code is below.
[...]
Sorry but I couldn't find the plugin. Is there maybe a separate Plugin download page ?

Wolle
Logged
Pages: [1] 2   Go Up
 

Page created in 0.025 seconds with 20 queries.