News module not showing when no News

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
hyde
Forum Members
Forum Members
Posts: 10
Joined: Thu Jul 17, 2008 9:16 am

News module not showing when no News

Post by hyde »

Is it possible to install the News Module but have it only appear when there actually is news? i.e. if there are no news items, I don't want the news header to show up without any content.

I have tried searching for this in the forum but didn't find anything; maybe someone else can point me in the right direction for this.
geepers
Dev Team Member
Dev Team Member
Posts: 84
Joined: Thu Nov 22, 2007 10:41 pm

Re: News module not showing when no News

Post by geepers »

This is not an answer, but an additional request/desirable for the News module.

Would be fabulous to be able to have 'default' message that displays if there are no current entries.

Something to the effect, 'No recent News, please check the News archives'.

Just a thought. :)
geepers
Dev Team Member
Dev Team Member
Posts: 84
Joined: Thu Nov 22, 2007 10:41 pm

Re: News module not showing when no News

Post by geepers »

Took a quick second to think this through - here's one way to achieve the latter request (mine).

Edit the 'Summary' template that you are using. I placed the header 'NEWS' within here as well at the top of the page.

I then just entered a new smarty

Code: Select all

{if}{/if}
. Here's the snippet below:

Code: Select all

{if pagecount < 1}
<p>Please check our news archives for a list of recent entries.<br />
<a href="/news/">View 'News'</a></p>
{/if}
You could add onto the lang/en_US.php file to include a new variable, maybe $lang['nonews'] to assign the html used above, then call it within the summary template using {$nonews}.
geepers
Dev Team Member
Dev Team Member
Posts: 84
Joined: Thu Nov 22, 2007 10:41 pm

Re: News module not showing when no News

Post by geepers »

Further to the previous post, the first request could be achieved by removing the default

Code: Select all

<h2>News</h2>
That appears within the page template, and relocating it to the top of the 'Summary' template, and wrap it within the following code:

Code: Select all

{if $pagecount => 1}
<h2>News</h2>
{/if}
Basically, if there's no entry, there's no $pagecount.
Post Reply

Return to “Modules/Add-Ons”