Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Formatting Articles for online newsletter

Formatting Articles for online newsletter
Thread Tools
Senior User
Join Date: Feb 2000
Location: Webster, NY, USA
Status: Offline
Reply With Quote
Oct 27, 2003, 02:31 PM
 
Hello,

I am working for a non-profit group. We put out a newletter on a weekly basis. Currently it sits on an asp page that I developed (limited asp skills) which pulls the articles from a database.

My boss asked if we could change the format so that we have a page similar to what MacNN does where it gives you a few lines of a story and then says click here to read full story.

I don't know an efficient way to do this, one thing I thougt that will work but seems shoddy at best is to take the body of the article, loop through it one character at a time grabbing 100 charcters (arbitrary number) and then keep looping grabing one character at at time until I get a space...

While I am pretty certain that would loop, I am sure there is a better way to do this...can someone give me an idea...

Thank you,

O
B unce!
     
Registered User
Join Date: Sep 2002
Location: New York City
Status: Offline
Reply With Quote
Nov 11, 2003, 05:58 AM
 
Just off the top of my head, I could think of 2 possible approaches:

1) [in very silly psuedo-code...]
tempString = article_from_db
tempString2 = SubString( tempString, 0, 100 )
x = locationOfLastSpaceChar( tempString2 )
articleIntroText = SubString( tempString2, 0, x )

2) have a db field for the article's intro text (I worked on a project at a Fortune100 company that had us use this approach) This implementation would let an administrative user view the article and possibly edit/specify the intro text to the article

Hope this helps.

-Ben
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Nov 11, 2003, 06:07 AM
 
Originally posted by NDBounce:
Hello,

I am working for a non-profit group. We put out a newletter on a weekly basis. Currently it sits on an asp page that I developed (limited asp skills) which pulls the articles from a database...
I hate mangled intros that arbitrarily cut off sentences so the context is lost. I'd try an algorithm that looks for either the first full stop or the first newline character (you're using unformatted text, right?) so that at least you have a fully-formed intro sentence to work with.

On the other hand, Smarty has an inbuilt 'trim' function that can do what you want - check it out at smarty.php.net
Computer thez nohhh...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:19 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2