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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Kevin C
Forum Members
Forum Members
Posts: 10
Joined: Tue Dec 11, 2007 4:48 pm

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

Post 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}
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

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

Post by katea »

Well this is quite an old post, but this no longer works!
jgroome
New Member
New Member
Posts: 5
Joined: Sat Jul 18, 2009 4:05 pm

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

Post by jgroome »

Should that ne '' be there?
JeremyBASS

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

Post by JeremyBASS »

jgroome wrote: Should that ne '' be there?
that's the smarty version of !=
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

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

Post 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}
Last edited by katea on Wed Aug 26, 2009 4:26 pm, edited 1 time in total.
JeremyBASS

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

Post 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
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

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

Post 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
JeremyBASS

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

Post 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
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

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

Post 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.
Post Reply

Return to “Modules/Add-Ons”