Page 1 of 1

Customizable Entries Archive - hiding inactive years ...

Posted: Fri Feb 05, 2016 10:02 am
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?

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

Posted: Fri Feb 05, 2016 11:29 am
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

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

Posted: Fri Feb 05, 2016 11:33 am
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'.

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

Posted: Fri Feb 05, 2016 1:25 pm
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);
            }

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

Posted: Fri Feb 05, 2016 1:51 pm
by Christine
Brilliant! It worked perfectly. Thank you so very much :) .