How to set default newest record in detail area

Hi, I have a news page with a list of news items, if you click a news item it will show on the detail area of the page. This works perfectly however I would like to always display the latest news item in the detail area when the page loads, before anything is selected. This is my page so far:

Thank you

how do you display the detail region. Is it another query that executes on click of the main list?
Thank you

PS your link leads to a forbidden access page.

Hi, it’s the same query. There are no restrictions on the page, however it is not a secure page.Try and click on the news link for the same pge.

Thank you

Getting an Error 403: Forbidden message

Which country are you accessing from? I have a htaccess file with country restrictions, will include your country code.

Actually I’ve just removed the htaccss altogether so should be fine to see the page now.


Athens Greece here…

I’ve just removed the htaccss altogether so should be fine to see the page now.


To get the last record i would normally just use a query sorted on the news_date descending so the last record is first and then use a LIMIT 1 clause to only select the last record. The query is simple however i have no idea off the top of my head how to set a LIMIT clause in Wappler but i am sure someone will.

This is often accomplished with a paged query where you set the limit to 1, but I don’t know if it is the right approach in his case.

This one you want to display on page load?

Yes, that should do it fine @t11, never though of doing it that way. Paged query, descending date, limit 1

Always the latest news item, at the moment it is test news item :slight_smile: Thank you.

The paged query set to 1 will work to always display the latest news item by default on page load, but after that I want people to be able to click on headlines and show the news in the same detail area. At the moment I have it set to show if there is a value for the news id, so it is blank on page load. Do you think a conditional show/hide somehow to show the news in the same area?

Thanks for all your replies and advice,much appreciated. AJ

This is not tested but think it will work.
1.You can create a cookie named ‘paging’
2.Initially set it as value=1 and when the user clicks on any of the other links set it to 15
3.Also set the paging to be shown when the cookie value > 1
This way it won’t display when you only show the first item

Hope it helps
Thank you!

Thanks, that would probably work, but I did it a simpler way, using the paged query limit 1 as suggested, and duplicating the detail region, however hiding the second detail region when a value of news_id is present, so showing when none is selected. Works like a dream, thanks everyone for the help.

1 Like