Customizable Entries Archive - hiding inactive years ...

Creating and modifying plugins.
Post Reply
Christine
Regular
Posts: 54
Joined: Wed Mar 25, 2009 11:50 pm

Customizable Entries Archive - hiding inactive years ...

Post by Christine »

I really like this plugin, and have managed to tweak a couple of things like changing the default sort order and getting rid of the author field.

I'd really like to be able to hide the years there are no blog posts in the year dropdown box... any way to do this?
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Customizable Entries Archive - hiding inactive years ...

Post by yellowled »

Christine wrote:I'd really like to be able to hide the years there are no blog posts in the year dropdown box... any way to do this?
I don't use or even know the plugin at all. There might be a config option for this, but you have probably already checked the plugin config?

YL
Christine
Regular
Posts: 54
Joined: Wed Mar 25, 2009 11:50 pm

Re: Customizable Entries Archive - hiding inactive years ...

Post by Christine »

Yeah, I have checked the config options, unfortunately there's nothing like that there - only options are permalink url and 'format as article'.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Customizable Entries Archive - hiding inactive years ...

Post by Timbalu »

Christine wrote:I'd really like to be able to hide the years there are no blog posts in the year dropdown box... any way to do this?
I would say: No!
And this, since that is build by a simple counter which does not really interfere with entries, accept for the start year.

Code: Select all

            $custom_sortyears = array();
            $custom_sortyears[] = array('value' => 'all', 'desc' => COMMENTS_FILTER_ALL);
            for ($i = $first_year; $i <= date('Y'); $i++) {
                $custom_sortyears[] = array('value' => $i, 'desc' => $i);
            }
So I assume you have the years 2006, 2007, 2008 ....counting up to 2016 and do not want to have 2007, 2009 and 2012, since you were lazy and did not post any entries in these years, right?

You could "hack" this, since this are probably years that do not change any more, replacing the above part by

Code: Select all

            $exclude_years = array('2007','2009','2012');
            $custom_sortyears = array();
            $custom_sortyears[] = array('value' => 'all', 'desc' => COMMENTS_FILTER_ALL);
            for ($i = $first_year; $i <= date('Y'); $i++) {
                if (in_array($i, $exclude_years)) continue;
                $custom_sortyears[] = array('value' => $i, 'desc' => $i);
            }
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Christine
Regular
Posts: 54
Joined: Wed Mar 25, 2009 11:50 pm

Re: Customizable Entries Archive - hiding inactive years ...

Post by Christine »

Brilliant! It worked perfectly. Thank you so very much :) .
Post Reply