Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

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

$
0
0

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>

  <metacharset="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 --->

  <divalign="left">

  <cfoutputquery="myQuery1">

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

                                        <hr>

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

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

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

                                        #len(LEFT(nonhtml,300))#

  <br><br><br>

  </cfoutput>

  </div>

  </body>

</html>



Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>