Page 1 of 1

[solved] Show excerpt of news detail if summary does not exist

Posted: Thu Dec 27, 2007 7:35 pm
by Kevin C
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}

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 2:21 pm
by katea
Well this is quite an old post, but this no longer works!

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:21 pm
by jgroome
Should that ne '' be there?

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:23 pm
by JeremyBASS
jgroome wrote: Should that ne '' be there?
that's the smarty version of !=

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:23 pm
by katea
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}

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:26 pm
by JeremyBASS
katea 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.
'' 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

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:28 pm
by katea
JeremyBASS wrote:
katea 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.
'' 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
Well the single didn't work for me in this instance ... but the double did

Re: [solved] Show excerpt of news detail if summary does not exist

Posted: Wed Aug 26, 2009 4:31 pm
by JeremyBASS
katea wrote:
JeremyBASS wrote:
katea 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.
'' 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
Well the single didn't work for me in this instance ... but the double did

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

Posted: Wed Aug 26, 2009 8:39 pm
by katea
JeremyBASS wrote:
katea wrote:
JeremyBASS 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
Well the single didn't work for me in this instance ... but the double did

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
It is indeed.