3 Replies Latest reply on Apr 8, 2014 12:22 AM by BKBK

    How can I change my code so it displays the first 200 characters of text?

    Cyu504

      Hi. I'm teaching myself ColdFushion.  I'm creating a page to show a list of news articles. I want to show the first 200 characters of the text. I store my data (article content as text) in mySQL. Everyone works except that it's not displaying the first 200 characters of the text. It displays about 30 characters. I've been looking at my code for a long time and tried the "rereplace" method but it doesn't work. Can someone give me a hint on what's missing? Thanks a lot!

       

      <!DOCTYPE html>

      <html>

        <head>

                          <title>Assessment Project</title>

        <meta charset="UTF-8">

        </head>

        <body>

        <!--- Page Title --->

                          <h3>Article Listings</h3>

       

        <!--- Page Content --->

        <!--- Display article title, author, date, first 200 characters

                          of the article content and a link to view the full article --->

        <div align="left">

        <cfoutput query="myQuery1">

        <b><a href="full_article_view.cfm?ID=#article_ID#" style="color:##000000; text-decoration: none;">#ucase(myquery1.article_title)#</a></b>

                                              <hr>

                                              <p style="color:##848181; font-size:12px">#myquery1.article_author# :: #myquery1.article_date#</p>

                                              <cfset nonhtml=reReplace(myquery1.article_content, "<[^>]*>,[[:space:]]","","ALL")>

                                              #LEFT(nonhtml, 200)# ... <a href="full_article_view.cfm?ID=#article_ID#">Read More</a>

                                              #len(LEFT(nonhtml,300))#

        <br><br><br>

        </cfoutput>

        </div>

        </body>

      </html>