Forum

Thread tagged as: Question

Perch function to hide a uneditable element

I have a news button (a link to the news page) that should only be visible when there are some news posted. The button itself is not editable, I am looking for a solution to change its appearance (e.g. display: none/inline;) within Perch. Is there a function for this available? Thanks a lot!

Martin Stettler

Martin Stettler 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to fetch the latest news item and see if you get anything back. How are you managing the news?

I don't think that's the right way, because the news page is always avaliable, old news are archived there. But if the latest one is old, it's not worth to show the news button, you just get there by clicking archive. So the question is more if there exists a function to make a certain div visible or hide it. Do you see any possibility?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can show and hide items using conditionals in your template.

https://docs.grabaperch.com/docs/templates/conditionals/

Great, works perfect! Many thanks