I have some users who don't always enter a summary for the news items they create. Most do, but some don't. If a news item does not have a summary, the default template displays the entire article, and this looks bad on the summary page.
I made a couple small changes to the summary template to display the summary if it exists, but if it does not, display the first 100 characters of the detail. It's a pretty simple change, but I didn't see any other examples of it in the forums, so here it is.
Here's what I modified in the summary template - additions are in red:
{if $entry->summary ne ''}
{eval var=$entry->summary}
[{$entry->morelink}]
{else if $entry->content}
{eval var=$entry->content|truncate:100}
{/if}
[solved] Show excerpt of news detail if summary does not exist
Re: [solved] Show excerpt of news detail if summary does not exist
Well this is quite an old post, but this no longer works!
Re: [solved] Show excerpt of news detail if summary does not exist
Should that ne '' be there?
Re: [solved] Show excerpt of news detail if summary does not exist
that's the smarty version of !=jgroome wrote: Should that ne '' be there?
Re: [solved] Show excerpt of news detail if summary does not exist
It should be a double quote ....It may of been a typo , but this is quite an important feature which I was looking for so thought I'd make people aware 
{if $entry->summary ne""}
{eval var=$entry->summary|truncate:100}
{$entry->morelink}
{else if $entry->content}
{eval var=$entry->content|truncate:100}
{/if}

{if $entry->summary ne""}
{eval var=$entry->summary|truncate:100}
{$entry->morelink}
{else if $entry->content}
{eval var=$entry->content|truncate:100}
{/if}
Last edited by katea on Wed Aug 26, 2009 4:26 pm, edited 1 time in total.
Re: [solved] Show excerpt of news detail if summary does not exist
'' or "" is valid... just in what you're doing makes the diff... but to the pointkatea wrote: actually, it should be
ne ""
that works ... It may of been a typo ... but I just wanted to bring to everyone's attention that it was wrong... As it's quite an important part.
If you look to the news defaults there is this basic idea already done for you... I'd look there and work from that... Hope that helps
Cheers
Jeremy
Re: [solved] Show excerpt of news detail if summary does not exist
Well the single didn't work for me in this instance ... but the double didJeremyBASS wrote:'' or "" is valid... just in what you're doing makes the diff... but to the pointkatea wrote: actually, it should be
ne ""
that works ... It may of been a typo ... but I just wanted to bring to everyone's attention that it was wrong... As it's quite an important part.
If you look to the news defaults there is this basic idea already done for you... I'd look there and work from that... Hope that helps
Cheers
Jeremy
Re: [solved] Show excerpt of news detail if summary does not exist
katea wrote:Well the single didn't work for me in this instance ... but the double didJeremyBASS wrote:'' or "" is valid... just in what you're doing makes the diff... but to the pointkatea wrote: actually, it should be
ne ""
that works ... It may of been a typo ... but I just wanted to bring to everyone's attention that it was wrong... As it's quite an important part.
If you look to the news defaults there is this basic idea already done for you... I'd look there and work from that... Hope that helps
Cheers
Jeremy
that's odd... I use {if $foo != ''} all the time... may-be it's do to the ne ... So this is solved yes?
Cheers
Jeremy
Re: [solved] Show excerpt of news detail if summary does not exist
It is indeed.JeremyBASS wrote:katea wrote:Well the single didn't work for me in this instance ... but the double didJeremyBASS wrote: '' or "" is valid... just in what you're doing makes the diff... but to the point
If you look to the news defaults there is this basic idea already done for you... I'd look there and work from that... Hope that helps
Cheers
Jeremy
that's odd... I use {if $foo != ''} all the time... may-be it's do to the ne ... So this is solved yes?
Cheers
Jeremy