Jump to content

Module: ProcessDateArchiver


u-nikos

Recommended Posts

ProcessDateArchiver

ProcessWire Date Archiver Process

Automatically archives pages based on a Datetime field (e.g. /news/2013/01/03/some-news-item/).

Behavior

- When you add a page with a specified template, the module will automatically create year/month/day archives for it.
- When you change the date in a specified Datetime field, the page is automatically moved to the correct year/month/day archive.
- When moving or trashing a page, the module will automatically clean up empty year, month and day archives.

How to create an archiving rule

1. Go to the Setup -> Date Archiver screen in the ProcessWire admin.
2. Click on Add New Archiving Rule.
3. Specify the template that should be archived (typically the news-item template).
4. Specify the Datetime field that should be used to determine the date to archive by.
5. Specify the template that should be used for creating year archives.
6. Optionally specify the template that should be used for creating month archives.
7. Optionally specify the template that should be used for creating day archives.
8. Click Add Rule.

Tips and tricks

- Configure the archive templates that will contain other archives to sort its children by name.
- Configure the archive template that will contain the news items to sort its children by the specified Datetime field.
- You will improve usability if you dont allow the user to create date archives manually.

How to Install

1. Install the module by placing ProcessDateArchiver.module in /site/modules/.
2. Check for new modules on the Modules screen in the ProcessWire admin.
3. Click Install for the Date Archiver Process.

Module download:
https://github.com/u...hive/master.zip

Module project:
https://github.com/u...ssDateArchiver/

n63lg4.jpg

  • Like 13
Link to comment
Share on other sites

i ran into an problem when i try to install the module. downloaded the module -> copied the file into the modules directory. when i look for new modules in the backend this error messages pops up: Parse Error syntax error, unexpected '[' (line 367 of /var/www/lupo/site/modules/ProcessDateArchiver/ProcessDateArchiver.module).

Line 367 begins with $this->fuel('breadcrumbs')...

public function ___executeAdd() {

        $this->setFuel('processHeadline', $this->_('Add Archiving Rule'));
        $this->fuel('breadcrumbs')->add(new Breadcrumb('./', $this->getModuleInfo()['title]));
        return $this->renderRuleForm();
    }

    /**
     * Executed when ./edit url for module is accessed.
     *
     */
    public function ___executeEdit() {

        $this->setFuel('processHeadline', $this->_('Edit Archiving Rule'));
        $this->fuel('breadcrumbs')->add(new Breadcrumb('./', $this->getModuleInfo()['title']));
        return $this->renderRuleForm();
    }

greetings

Link to comment
Share on other sites

thanks u-nikos for downgrading to php 5.3  :) it works fine now but when i submit a new rule i become a site-not-found error because the module directs to a wrong url. in my local environment it calls localhost/processwire/setup/date-archiver/. the right url would be localhost/pw/processwire/setup/date-archiver/.

Link to comment
Share on other sites

Who uses php 5.4. :P Seriously I wouldn't be able to use this module and many others too. Thanks for removing it.

Yeah I didn't really think about version compatibility, will try to do so in the future :)

thanks u-nikos for downgrading to php 5.3  :) it works fine now but when i submit a new rule i become a site-not-found error because the module directs to a wrong url. in my local environment it calls localhost/processwire/setup/date-archiver/. the right url would be localhost/pw/processwire/setup/date-archiver/.

I've changed the $session->redirect argument from $page->path to $page->url, so it should be fixed now.

Link to comment
Share on other sites

  • 3 weeks later...

Hey Marty,

No need to do that manually, you can put a little snippet in one of your templates to save the pages automatically (be sure to remove the snippet when you're done).

Here is a little example:

<?php foreach ($pages->find('template=news-item') as $item) {
    $item->save();
} ?>
Link to comment
Share on other sites

Just had a look at the modules and found this one - great addition, thanks! I was about to build an news-archive and this module seems to do exactly what i need.

Just one question...

Before I found this module I already had prepared this pagetree:

News (not-viewable)

  - Recent News (template = news_overview)

         - Lorem Ipsum (template = news_article)

         - Dolor Sit (template = news_article)

 - Archive (template = news_overview)

The whole pagetree is shon on the page as dropdown - one can just klick "Recent News" and "Archive". In the archive i planned to have an overview of the passed years.

Now i installed the module, choose the template "news_article" to be archived and the template "news_overview" as year archive template.

After i saved an article the page "2013" was added under "News", the page "Archive" was deleted. Should this be like this?

I guess the module works in the way it will place the archive pages under the same parent where the template exists, which is chosen to be archived - but should an existing page be deleted?

One more question:

Is it possible to have the actual year news items listed under a defined page, e.g. "Recent News" and just the items of the passed years listed under a page which is named like the year?

Link to comment
Share on other sites

Hey Doolak! Yes this is intended behaviour. I'll explain what the module does:

1. When a page is saved with the news_article template, the module will find the first parent page that isn't a year/month/day template (in this case: News).

2. Then it'll create the year/month/day templates under that parent page, and move the news_article into it (in this case: it'll create the 2013 year archive under News, and move the Lorem Ipsum news_article into it).

3. After the news_article is moved, the module will cleanup empty year/month/day archives (in this case: it'll delete the Recent News and Archive pages because you've told the module that they are year archives, and they are cleaned up because they're empty).

If you want to retain the Recent News and Archive pages, you should create an different template for the year archives, like "news_year_archive" and tell the module to use this template for the year archives.

Little example:

- News (template=news)

    - 2013 (template=news_year_archive)

        - Lorem Ipsum (template=news_article)

        - Dolor Sit (template=news_article)

    - Recent News (template=news_overview)

    - Archive (template=news_overview)

Although I'm not sure if you really need the Recent News and Archive pages (because News could already show the recent news, and the 2013 page is already an archive), but I hope this helps u :)

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
Sorry for the cross-post but I have a problem whereby I can't move a page out of the Trash into a section of the page tree using PDA. My only way around it is to change the page template, move it then, change the template back. Wondering if this behavior is expected or not.

In cases where a drag-drop isn't supported (like on a cellphone, tablet, etc.) you would edit the page, click to the "settings" tab, and change the parent from there. If it still doesn't let you put it where you want to, you may need to adjust the family settings of the relevant templates. Those family settings in each template optionally control where pages will be allowed to ultimately live or be moved to. 

Link to comment
Share on other sites

Hi Ryan,

This all in desktop browsers. I thought of the 'family' settings and removed that first up. Moving that page out of the Trash still didn't work. My fix was to change the page template (and the one used in the Date Archiver settings) and then move it out, change the template back to the original - and in doing that the Date Archiver finds it and shuffles it away.

Link to comment
Share on other sites

Strange I wonder what was blocking it from coming out of the trash. If it wasn't the family settings, I really don't know what it could be. But if you find it turns up again, let me know. Btw, when you said PDA, I thought you were talking about an old school mobile device or something. :)

Link to comment
Share on other sites

  • 1 month later...

Hello,

I was just wondering, in the tips you mention '- You will improve usability if you dont allow the user to create date archives manually.' Can you elaborate on what you mean and how to go about it? Is it done with the family or access settings for each template?

Thanks

Never mind I figured it out. Thanks again for this module.  :-)

Edited by antknight
Link to comment
Share on other sites

  • 6 months later...

I am trying out your module as a solution to my question here and it works great for archiving. Thanks for sharing it.

I did have one question though. Using your example structure above, I noticed that if the year "2013" page is already created in the tree structure and if you would go to create a new article page under the "News" a new  "2013"  is created and the new article is placed under that page instead of the already created "2013" page.

News
    - 2013
     -- Article

I know the logical sense would be to create a new article under the 2013 page, but users may become confused by that. Is there a way to check if an archive date page is already created under its current parent? If so, to place that new article in the already created one, if not then create it?

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Forget the second question, please!

That sorting is fine as it is - i forgot that if i want to display the recent years items under "Recent news" that can be easily done through the API... ;-)

Hey, I'm fairly new to PW so i'm trying this module which seems to do what i need. But to the deletion or rather renaming of existing pages to year it is messing with my menu layouts.

How can i have each category achieve under it's own page head.

Home

- Category 1

      -Year 2014

        -Page 1

- Category 2

      -Year 2014

        -Page 2

Right now it changes my structure to

Home

-Category 1

    {unpublished}

- 2014

    -Page 1

    -Page 2

Which in my opinion isn't very user friendly of navigation, if i have my menu markup based on second level pages (From Home).\

If i can get any assistance, i would greatly appreciate it.

Link to comment
Share on other sites

  • 4 weeks later...

Great module but I have a little problem.

I have a news article template named "news_item" which has title, date, text and image fields. On my news page I'm allowed to create new children with the news_item template. I've further created templates for news_year, news_month and news_day. These are empty templates with just the title field.

I've set-up the Date Archiver for the template "news_item" to use its date field as the date, and to use each of the news_year, month and day templates as per. However, now when I create new news items they get archived correctly up to the month but for the day a new page is created every time resulting in duplicates.

E.g. if I posted two articles today they would be archived:

news/2014/03/24/article

news/2014/03/24-2/another-article (although 24-2 is still displayed as just 24 in the page-tree)

Furthermore the day page is created using the month template even though it's been set-up to use the news_day template.

Is there something I'm doing wrong?

Link to comment
Share on other sites

  • 3 months later...

Great module but I have a little problem.

I have a news article template named "news_item" which has title, date, text and image fields. On my news page I'm allowed to create new children with the news_item template. I've further created templates for news_year, news_month and news_day. These are empty templates with just the title field.

I've set-up the Date Archiver for the template "news_item" to use its date field as the date, and to use each of the news_year, month and day templates as per. However, now when I create new news items they get archived correctly up to the month but for the day a new page is created every time resulting in duplicates.

E.g. if I posted two articles today they would be archived:

news/2014/03/24/article

news/2014/03/24-2/another-article (although 24-2 is still displayed as just 24 in the page-tree)

Furthermore the day page is created using the month template even though it's been set-up to use the news_day template.

Is there something I'm doing wrong?

I'm having the same issue, but I'm only using the year -- and using PW v2.4, which isn't specified as compatible anyway...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...