Jump to content

Set pages to disable after certain # of days from post date


lucas
 Share

Recommended Posts

Do you need them actually tagged somehow as expired, or could the selector in your template file just exclude all posts before a certain date?

$pages->find("created<xxxx");

or perhaps from a custom published_date field, or whatever.

  • Like 2
Link to comment
Share on other sites

Do you need them actually tagged somehow as expired, or could the selector in your template file just exclude all posts before a certain date?

$pages->find("created<xxxx");

or perhaps from a custom published_date field, or whatever.

hey adrian, yep no need to tagged them as expired, just exclude them.

  • Like 1
Link to comment
Share on other sites

Is it possible to change simple the parent page? For eg from /posts/ to /archive/ ?

Yep :)

$p = $pages->get(xxxx);
$p->parent = $pages->get("/archive/");
$p->save();

But with that approach, you might find the Date Archiver module useful: http://modules.processwire.com/modules/process-date-archiver/

Edited by adrian
Added Date Archiver link
  • Like 2
Link to comment
Share on other sites

Easy as expected...

Date archiver sounds very interesting, too for good/speaking newspostsurls.

One simple question stands - both solutions - change parent and setup pages with date archiver:

With enabled path history module (core) are the urls/paths keep working for this pages?

Important for seo with news posts I think...

In my former cms articleaddon you could set the URL different from the logical place in backend.

Link to comment
Share on other sites

The path history module should take care of those redirects for you. I haven't actually used the date archiver module, so not sure if there is something built-in to take care of this, but from a quick read, it doesn't sound like it.

One other possibility is http://modules.processwire.com/modules/process-redirect-ids/ which allows URLs to contain the ID of the page, so even if the name/path changes, the link will always work - just like the way this forum uses the topic ID rather than the title part of the url to load the page.

Link to comment
Share on other sites

thanks in advice!

my first pw project is comming along - there is a not fancy newspage to setup so i'll give the /archiv/ solution a try and report.

i think for the beginning i wonna accomplish the most stuff with "onboard" technics and later go deeper with modules.....to learn first properly the system* then the scope of the hooks and modules.

*since i've done webdesign/dev as a second-job (working for a social NGO the maintime - and have a little farm at home) i'm always in lack of time especially in the summer (harvest)

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
 Share

×
×
  • Create New...