Hey,
I have been trying to create a monthly archive with posts a la standard blog style in D6, but with no success. The 'Monthly Archive' module is not updated, not yet anyway.
I have tried views, and in the views description it says:
You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
and it's what I have been trying to do. I have been looking at http://drupal.org/node/52037 but the import doesn't work correctly, it seems, and/or the code snippet. Could anyone help here? Perhaps update the above link to v.6 anyone, please?
Comments
Try this
Hi there, I was just looking for the same thing and discovered that views now has an archive view built in to it in the latest version for d6 here is the export of the one I am using:
$view = new view;
$view->name = 'archive';
$view->description = 'Display a list of months that link to content for that month.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('sorts', array(
'created' => array(
'id' => 'created',
'table' => 'node',
'field' => 'created',
'order' => 'DESC',
'granularity' => 'second',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'created_year_month' => array(
'id' => 'created_year_month',
'table' => 'node',
'field' => 'created_year_month',
'default_action' => 'summary asc',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => 1,
'override' => 1,
'items_per_page' => '30',
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1',
'relationship' => 'none',
'validate_type' => 'none',
'validate_fail' => 'not found',
'default_argument_type' => 'fixed',
),
));
$handler->override_option('filters', array(
'status' => array(
'id' => 'status',
'table' => 'node',
'field' => 'status',
'operator' => '=',
'value' => 1,
'group' => 0,
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'blog' => 'blog',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('title', 'blog archive');
$handler->override_option('use_pager', '1');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'teaser' => TRUE,
'links' => TRUE,
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('path', 'archive');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('arguments', array(
'created_year_month' => array(
'id' => 'created_year_month',
'table' => 'node',
'field' => 'created_year_month',
'default_action' => 'summary asc',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => 1,
'override' => 0,
'items_per_page' => '30',
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1',
'relationship' => 'none',
'validate_type' => 'none',
'validate_fail' => 'not found',
'default_argument_type' => 'fixed',
),
));
$handler->override_option('use_ajax', '1');
$handler->override_option('block_description', 'Archive list');
$handler->override_option('block_caching', -1);
bookmarked
bookmarked
Thanks fibie, Your
Thanks fibie,
Your code helped me a lot. I had created a view but there was some problem in my view that it was not displaying the the details when i click on the the months.
But now, I am getting it very nicely. Thanks a lot.
If the OP is on D6 also (and
If the OP is on D6 also (and the post says it's d6) he can just enable the same view you just exported, lol.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
The one I posted is
The one I posted is customised a little so thought I would post anyway, but you're right probably not worth the trouble to be that helpful
;-)
I appreciate that you took
I appreciate that you took the time to answer, and I am sure it will help others.
The project I was working on has been paused up until now, so I actually imported your code and double checked things and it seems like I succeeded 4 month ago. :)
Thanks,
--
hook_world() is broken.
Hello, I am having problems
Hello,
I am having problems with the block view of this. I Imported the view, and the page view appears correctly when I open the appropriate URL. But I also activated the block view and it doesn't show up. I opened the Html source code and there is no sign of that block having been inserted.
If I am administrating the view and choose the preview for the block view, that preview is correct.
Any ideas why though the block preview is correct, the actual block never appears?
Best regards,
Christian