ZenphotoCMS Forum
Print news link only when news is present and published - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Print news link only when news is present and published (/thread-10621.html)



Print news link only when news is present and published - fretzl - 2012-11-29

Scenario:
A menu with a "News" link to news.php.
This link is wrapped in some HTML.
What I'd like is: to not print the HTML/News-link if there is are no news-tems or only unpublished news-items.

Any tips ?




Print news link only when news is present and published - acrylian - 2012-11-29

If using the official menus, no way without modifiying. If a custom (static) menu try getNumNews(). It uses the class method getArticles/getCombiNews internally so it should not return unpublished items unless - as alway - loggedin with the appropiate rights.




Print news link only when news is present and published - fretzl - 2012-11-29

Thanks. I'll give it a try.




Print news link only when news is present and published - fretzl - 2012-11-30

Works great!
if(getNumNews(true) > 0) {....}




Print news link only when news is present and published - acrylian - 2012-11-30

I guess, If not you would have had found a bug..;-)




Print news link only when news is present and published - vincent3569 - 2012-11-30

Hi
btw, in zpArdoise, I only use
if (getNumNews() > 0) {...}