Thomas108 Posted October 22, 2014 Share Posted October 22, 2014 Hi. I am using the news system from this tutorial: http://wiki.processwire.com/index.php/Simple_News_System Since the news are just short announcement for one time events, I would like to achieve the following: I want to give the editor a field for setting an expiry date. Expired news should automatically be removed from the main news page, but should be accessible in a folder "older entries". I searched the forum but I didn't find anything similar. Maybe something like this could work, but I don't know how to code this properly: $newsposts = wire("pages")->find("parent=/news-artikel/, $category, template=news, limit=10") (CONDITION)...WHERE EXPIRY DATE FIELD IS NOT EXPIRED What do you think about this approach? Could it work and if so, how is this written properly? Thanks for your help in advance. Thomas PS: Here is the part from my code which fetches the news for the main news page: $newsposts = wire("pages")->find("parent=/news-artikel/, $category, template=news, limit=10"); $out =" "; foreach($newsposts as $newspost){ $out .="<div class='newsitem'>"; $datum1; $datum1 = $newspost->publish; $datum1 = date("d.m.Y - H:i", $datum1); $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->summary}</p>"; if($newspost->news_image){ $out .="<a href='{$newspost->url}' class=''>"; $out .="<img class='align_left' src='{$newspost->news_image->size(300)->url}'>"; $out .="</a>"; } $out .="</div>"; } PSS: For the folder "older entries" I guess, I can just use the original code again. Link to comment Share on other sites More sharing options...
mr-fan Posted October 22, 2014 Share Posted October 22, 2014 Some helpfull links to go: https://processwire.com/talk/topic/7359-set-pages-to-disable-after-certain-of-days-from-post-date/#entry70911 http://modules.processwire.com/modules/process-date-archiver/ but be ware of the path changes....for SEO (bookmarks and so on) regards mr-fan 1 Link to comment Share on other sites More sharing options...
kongondo Posted October 22, 2014 Share Posted October 22, 2014 (edited) There is the Schedule Pages module....for auto-expiring...but not moving... ...but you can achieve that with a simple module/hook. But Date Archiver looks like it will do what you want... Edited October 22, 2014 by kongondo Link to comment Share on other sites More sharing options...
JFn Posted October 22, 2014 Share Posted October 22, 2014 Something like this should work: $newsposts = $pages->find("parent=/news-artikel, expiry_date<".time()); foreach($newsposts as $newspost){ $newspost->parent = "/older-entries"; $newspost->save(); } Link to comment Share on other sites More sharing options...
Thomas108 Posted October 22, 2014 Author Share Posted October 22, 2014 Thanks for all your answers. For now I successfully implemented Andre's code. But now I am aware of the url change. Would be great if I could somehow create a permanent 301 redirect to the new folder "older-entries" if someone wants to open a moved entry within the old folder "news-artikel". Any idea if this is possible? UPDATE: Just found the Redirects module. Maybe that can help me. Link to comment Share on other sites More sharing options...
adrian Posted October 22, 2014 Share Posted October 22, 2014 Enable the core module "Page Path History" and it will take care of the redirects for you. 1 Link to comment Share on other sites More sharing options...
Thomas108 Posted October 22, 2014 Author Share Posted October 22, 2014 Regarding my idea of using the Redirects module, I just found out that I'll probably need a wildcard function, which is not implemented in the module. @Adrian: The description of Page Path History sound very promising. Thanks for the link. I'll check it out. Link to comment Share on other sites More sharing options...
Soma Posted October 22, 2014 Share Posted October 22, 2014 Why all this complicated like moving and hooking and redirecting. I think it's as simple as only display news to a certain date time expired, and have a link to older news will just show all from a certain date time backward. This could be done with a urlSegment or a physical page "older-news" that only lists, well older news. No need to go fancy complicated. News pages stay where they are, chronologically. 4 Link to comment Share on other sites More sharing options...
adrian Posted October 22, 2014 Share Posted October 22, 2014 Not that soma's advise ever needs someone else's support, but I am in complete agreement - this approach is something I have done on several sites - it works great and saves lots of hassles and just seems more kosher. Link to comment Share on other sites More sharing options...
Thomas108 Posted October 22, 2014 Author Share Posted October 22, 2014 @soma: yep, uncomplicated sounds good. But I never used url segments before, so lets see... Tomorrow I'll check the different post about url segments. Have a nice evening. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now