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

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Sebastos
New Member
New Member
Posts: 7
Joined: Wed Dec 03, 2008 9:22 am

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

Post 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!
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

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

Post by Nullig »

You can use the truncate modifier in your news template, same as the other one.

Nullig
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

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

Post by irish »

Just change your template so that it uses the Smarty truncate method:

{$articleTitle|truncate:30}
Sebastos
New Member
New Member
Posts: 7
Joined: Wed Dec 03, 2008 9:22 am

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

Post by Sebastos »

Something like this? :


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


? thanks!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

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

Post 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...
Last edited by Anonymous on Tue Jan 13, 2009 5:08 pm, edited 1 time in total.
jadusdathe
Forum Members
Forum Members
Posts: 54
Joined: Sat Sep 20, 2008 3:50 pm

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

Post 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?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

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

Post 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
Sebastos
New Member
New Member
Posts: 7
Joined: Wed Dec 03, 2008 9:22 am

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

Post 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?
Last edited by Sebastos on Wed Jan 14, 2009 9:48 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

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

Post by Dr.CSS »

Must have something to do with it being a link, other wise not sure...
Post Reply

Return to “Developers Discussion”