Limit characters in summary News module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
tynmar

Limit characters in summary News module

Post by tynmar »

Hi !

I'd like to limit at 50 characters for each news with a link [more] in the end.
I think it's a smarty script to put in the template but I can't find it on smarty site.

for example :

Code: Select all

{if $entry->summary}
{if $entry->formatpostdate}{$entry->formatpostdate}{/if}
{eval var=$entry->summary limitcharacters='50'}
[{$entry->morelink}]
{/if}
I don't want to add a new param 'limitcharacters' to news module if it's not necessary. I want to use a smarty function.

Is this possible ?
Thanks a lot
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Limit characters in summary News module

Post by Dee »

Use Smarty's truncate modifier in the template:

Code: Select all

{$entry->summary|truncate:50}
There's also a Smarty summarize function included in CMSMS (plugins/function.summarize.php) which enables you to limit the number of words.

Regards,
D
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Limit characters in summary News module

Post by Dee »

Dee wrote: There's also a Smarty summarize function included in CMSMS (plugins/function.summarize.php) which enables you to limit the number of words.
To make it work, rename the file from function.summarize.php to modifier.summarize.php.
You can then use

Code: Select all

{$entry->summary|summarize:10}
to trim to 10 words.
I renamed the file in SVN so this won't be necessary in a next release.
tynmar

Re: Limit characters in summary News module

Post by tynmar »

Great !
truncate is exactly what I need.

Thanks
schug.trent
Forum Members
Forum Members
Posts: 28
Joined: Sun May 18, 2008 7:53 pm

Re: Limit characters in summary News module

Post by schug.trent »

I know this is an old topic, but can't find anything else on it. I have latest version of CMSMS and News Module

I tried the above methods to limited the number of words / characters that show up in a news summary, but neither seem to work.

Any other ideas?

Tried this and nothing:

Code: Select all

{if $entry->summary|summarize:10}
	<div id="summary">
		{eval var=$entry->summary}
	</div>

	<div id="moreLink">
		<<<{$entry->morelink}>>> 
	</div>

{/if}
Tried this and nothing:

Code: Select all

{if $entry->summary|truncate:50}
	<div id="summary">
		{eval var=$entry->summary}
	</div>

	<div id="moreLink">
		<<<{$entry->morelink}>>> 
	</div>

{/if}
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Limit characters in summary News module

Post by Nullig »

I believe you need to change it to:

{if $entry->summary}

{eval var=$entry->summary|truncate:50}



morelink}>>>

{/if}

Nullig
schug.trent
Forum Members
Forum Members
Posts: 28
Joined: Sun May 18, 2008 7:53 pm

[SOLVED]Re: Limit characters in summary News module

Post by schug.trent »

Thanks, worked perfect!
Gumir
New Member
New Member
Posts: 3
Joined: Thu Dec 08, 2011 7:43 pm

Re: Limit characters in summary News module

Post by Gumir »

Hi All

It took several centuries :) 2011
I know this is an very very old topic, but can't find anything else on it.

I try on 1.10.2 "Case Pilote" this test... but nothing...
various manipulations of the proposed methods - null result

yes... i found and see in folders
(root)/plugins/modifier.summarize.php
(root)/lib/smarty/plugins/modifier.truncate.php

rtfm this page - http://www.smarty.net/docsv2/en/languag ... runcate/// and more...

for testing placed and here - {if $entry->summary} and here {eval var=$entry->summary} and more sado-mazo

syntax error: invalid attribute name: '|truncate:200' (Smarty_Compiler.class.php, line 1550)
syntax error: invalid attribute name: '|summarize:200' (Smarty_Compiler.class.php, line 1550)

_____
after many attempts to find and asking for your help...
How to solve this trouble now?

Any help would be greatly appreciated.. thnx

*I'm newbie to CMSMS (a few days testing ) but not noob in CMS's
Locked

Return to “Modules/Add-Ons”