Page 1 of 1

how to show only a certain characters of a news article?

Posted: Mon Jan 12, 2009 10:20 pm
by Sebastos
Hi there,

At my work, we have a CMS based on PHP and smarty code. In that cms I can show for example a news article but with a "truncate" in the code, I can decide with that code how many characters of the message is shown before "..." is added after the preview text part.

Does anyone on here knows how to do that with the news module in cmsms? I'm really seeking to... then my site finaly is almost ready  :o

thanks!

Re: how to show only a certain characters of a news article?

Posted: Mon Jan 12, 2009 11:09 pm
by Nullig
You can use the truncate modifier in your news template, same as the other one.

Nullig

Re: how to show only a certain characters of a news article?

Posted: Tue Jan 13, 2009 9:55 am
by irish
Just change your template so that it uses the Smarty truncate method:

{$articleTitle|truncate:30}

Re: how to show only a certain characters of a news article?

Posted: Tue Jan 13, 2009 12:54 pm
by Sebastos
Something like this? :


{eval var=$entry|truncate:30->content}


? thanks!

Re: how to show only a certain characters of a news article?

Posted: Tue Jan 13, 2009 5:05 pm
by Dr.CSS
Maybe more like...

{eval var=$entry->content|truncate:30}

But this will only make the content have 30 characters and it has no "more link", except the title will link to full article but it has to be that you have no summary in the article and this needs to be in the summary template...

Re: how to show only a certain characters of a news article?

Posted: Tue Jan 13, 2009 7:44 pm
by jadusdathe
Im trying to do the same thing:

Code: Select all

<!-- Start Home News Slim -->

{foreach from=$items item=entry}
<div class="NewsSummary">

<div class="NewsSummaryLink">
<p class="text-blue">
	{$entry->titlelink|truncate:10}
</p>
</div>

{/foreach}

</div>

<!-- End Home News Slim -->
This doesnt work, my text is gone now.

Can anybody help please?

Re: how to show only a certain characters of a news article?

Posted: Tue Jan 13, 2009 9:56 pm
by Dr.CSS
Guess titlelink don't like that, tried it with :1 and still nothing but ... this link will show the uses of it, thanks to tyman00 in chat...

http://www.smarty.net/manual/en/languag ... uncate.php

Re: how to show only a certain characters of a news article?

Posted: Wed Jan 14, 2009 9:05 am
by Sebastos
Thanks a lot Mark! Any idea why the truncate is nog working with titles? This is actualy why I need it for haha! Is this perhaps a bug?
Should I dive in to the core php (if so...then how?) of the module and make changes in there?

Re: how to show only a certain characters of a news article?

Posted: Wed Jan 14, 2009 6:36 pm
by Dr.CSS
Must have something to do with it being a link, other wise not sure...