Jump to content

Loading page B instead of page A


Recommended Posts


even it's a funny idea as
- you'll be multiplying duplicate contents between this latest-article and... the latest article
- the content of this latest-article will change quite often
it's quite easy to achive, just use $pages->find  with template and sort by -date (with your own field naming convention) to get the id of your latest article on top of the code and then use $pages->get(xxxx)->content and so on to display the latest article content/images/... in the page

hope it helps

have a nice day

  • Like 3
Link to comment
Share on other sites

@Manaus This is a case where you should do a 302 redirect $session->location($article->url); rather than render different articles at the same URL. Otherwise folks won't be able to accurately bookmark it, and it'll confuse search engines, so it'd be an SEO problem. But I'll assume you know that and you want to do it anyway. What Zeka mentioned above is a good way to go, and probably the one I'd choose. But here's also another option below. It assumes you have a "latest-article" template and it is used by the page /latest-article/. 


$article = $pages->findOne("parent=/articles, sort=-created"); 
if(!$article->id) wire404();
echo $article->render();

If you are using prepend/append template files, then you'd also want to check the box to disable them in Setup > Templates > latest-article > Files (tab).  

  • Like 1
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...