forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: NeoID on November 29, 2005, 07:37:36 pm

Title: Hide albums from latest and random
Post by: NeoID 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?  :)
Title: Re: Hide albums from latest and random
Post by: donnoman 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;
}
Title: Re: Hide albums from latest and random
Post by: NeoID 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?
Title: Re: Hide albums from latest and random
Post by: Nibbler on November 29, 2005, 09:03:43 pm
http://forum.coppermine-gallery.net/index.php?topic=24327.0
Title: Re: Hide albums from latest and random
Post by: NeoID 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?  :)
Title: Re: Hide albums from latest and random
Post by: donnoman 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.
Title: Re: Hide albums from latest and random
Post by: noworyz 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?
Title: Re: Hide albums from latest and random
Post by: donnoman 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".
Title: Re: Hide albums from latest and random
Post by: noworyz 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!
Title: Re: Hide albums from latest and random
Post by: NeoID on November 30, 2005, 08:32:04 am
It works, thanks alot donnoman.  :D
Title: Re: Hide albums from latest and random
Post by: Joachim Müller on November 30, 2005, 09:11:01 am
Should this be moved to cpg1.4 plugin contributions (http://forum.coppermine-gallery.net/index.php?board=66.0) then?
Title: Re: Hide albums from latest and random
Post by: NeoID on November 30, 2005, 03:17:16 pm
Should this be moved to cpg1.4 plugin contributions (http://forum.coppermine-gallery.net/index.php?board=66.0) then?

I think yes... (sorry for posting in the wrong forum)  :)
Title: Re: Hide albums from latest and random
Post by: Joachim Müller 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.
Title: Re: Hide albums from latest and random
Post by: donnoman 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
Title: Re: Hide albums from latest and random
Post by: Joachim Müller 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?
Title: Re: Hide albums from latest and random
Post by: donnoman 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.
Title: Re: Hide albums from latest and random
Post by: Tranz 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);
Title: Re: Hide albums from latest and random
Post by: NeoID 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...) ^_^
Title: Re: Hide albums from latest and random
Post by: donnoman 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.
Title: Re: Hide albums from latest and random
Post by: wolle 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
Title: Re: Hide albums from latest and random
Post by: Nibbler on February 04, 2006, 01:20:15 pm
It's attached to one of the posts - http://forum.coppermine-gallery.net/index.php?topic=24350.msg112486#msg112486
Title: Re: Hide albums from latest and random
Post by: Joachim Müller on February 04, 2006, 04:08:47 pm
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.
Donnoman is absolutely right, that's something we agreed upon: no hooks (which would equal a new feature) will be added for an existing release to avoid confusion what version of a plugin will work with which version of coppermine. Only bug-fixes are permitted to be added to the cvs of a stable release. New features must only be added to the devel branch.
Title: Re: Hide albums from latest and random
Post by: txspaderz on April 26, 2006, 05:05:05 am
I'm trying to do this:  I want to keep from displaying one whole category.  I have a NSFW Gallery, that I don't want to be shown on the main page only.  I have blocked all the albums, but now when I go to that particular category, where I have blocked all the albums, I get an error: 
Critical error
There was an error while processing a database query 

Any suggestions?
Title: Re: Hide albums from latest and random
Post by: Tranz on September 18, 2006, 04:46:19 am
I just noticed today that the plugin causes the items in excluded album not to show up even when viewing the album: http://takethu.com/thumbnails.php?album=73

If I uninstall the plugin, the thumbnails show up. I downloaded the plugin again and did a diff and the only difference to my code is the list of excluded album ids.
Title: Re: Hide albums from latest and random
Post by: Stifler on October 16, 2006, 09:31:58 pm
Does this work?
Title: Re: Hide albums from latest and random
Post by: donnoman on October 17, 2006, 05:17:06 am
it's the attachment on this message: http://forum.coppermine-gallery.net/index.php?topic=24350.msg112486#msg112486
Title: Re: Hide albums from latest and random
Post by: Stifler on October 19, 2006, 01:36:58 am
Thank you donnoman.
Title: Re: Hide albums from latest and random
Post by: Nibbler on November 13, 2006, 11:37:19 pm
Try this code as codebase.php. It suppresses the filters when viewing the albums directly and is coded more simply.

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  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.
  ********************************************
  Coppermine version: 1.4.2
**********************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$thisplugin->add_filter('plugin_block','remove_meta_albs'); //index.php

if (!$_GET['cat']) {
$thisplugin->add_filter('post_breadcrumb','remove_meta_albs'); //thumbnails.php
if (!is_numeric($_GET['album'])) $thisplugin->add_filter('displayimage_init','remove_meta_albs'); //displayimage.php (MODDED PLUGIN HOOK)
}

function 
filter_meta_album() {

global $META_ALBUM_SET,$ALBUM_SET;
    
    
$unwanted_albs=array(45);
$META_ALBUM_SET.= ' AND aid NOT IN ('.implode(',',$unwanted_albs).')';
    if (
defined('DISPLAYIMAGE_PHP')) $ALBUM_SET $META_ALBUM_SET;
}

function 
remove_meta_albs($return) {
    
    static 
$run_once;
    if (!
$run_once) {
        
filter_meta_album();
        
$run_once=true;
    }
    return 
$return;
}
Title: Re: Hide albums from latest and random
Post by: studeo on November 14, 2006, 12:28:43 am
Thanks, That works better except for one issue.

If the excluded album is the ONLY album of a given member, when you click on that gallery from the index the latest addition and random image block under that album report "No images to display" You can click the one main album thumbnail to get to the thumbnail page however.

Thank You.
Title: Re: Hide albums from latest and random
Post by: Prowler9 on December 02, 2006, 05:11:07 am
Ok well I installed and did everything it says to do and I only have one problem.  Well when I click pictures in the filtered album i get No image to display. Is there something else I need to edit?? If so let me know thanks again for your time reading this post
Title: Re: Hide albums from latest and random
Post by: donnoman on December 03, 2006, 01:35:58 am
I just released Unwanted_Metas 2.0 that eliminates the need for  modding displayimage.php and has fixed all of the known issues, and includes a graphical interface to select the albums.

http://cpg-contrib.org/board/index.php?board=31.0
Title: Re: Hide albums from latest and random
Post by: studeo on December 03, 2006, 02:52:14 pm
Thanks for a new plugin.  If I may comment: The selection list only lists my own albums and shared albums....Some of the excludes I would do are uselessly large member galleries...they are not listed in the drop-down list...where can I add their album ID to the code manually since I cannot select them automatically?

Thank You Donnoman
Title: Re: Hide albums from latest and random
Post by: donnoman on December 03, 2006, 06:33:18 pm
unwanted_metas 2.1

12-03-2006 Added support for removing user albums
12-03-2006 Widened the configuration list box

http://sourceforge.net/project/showfiles.php?group_id=132063&package_id=213644

If you are looking for support on a cpg-contrib plugin the best place to get it (because I check there more often) is on the cpg-contrib forums

http://cpg-contrib.org/board/index.php?board=31.0
Title: Re: Hide albums from latest and random
Post by: studeo on December 03, 2006, 11:21:42 pm
Very nice plugin! Extremely useful.

One point though: If I exclude a user album and its 'the only' album by that user, no images are displayed on their album page except for the main gallery image at the top table. It makes sense that the album is excluded from all meta albums (random, latest). Is there anyway to isolate the exclusion to take effect on the index page only so it is not global?

Thanks again for the nice plugin!

Studeo
Title: Re: Hide albums from latest and random
Post by: Prowler9 on December 04, 2006, 02:18:19 am
Thank you sir ;)
Title: Re: Hide albums from latest and random
Post by: Joachim Müller on December 04, 2006, 03:55:24 am
One point though: If I exclude a user album and its 'the only' album by that user, no images are displayed on their album page except for the main gallery image at the top table. It makes sense that the album is excluded from all meta albums (random, latest). Is there anyway to isolate the exclusion to take effect on the index page only so it is not global?
Why do you reply here? Donnoman told you were to turn for support. ::)