Find First Paragraph
Today I had the need to create a script that would find the first paragraph in a string and use this as the extract for a news article.
So, I thought I’d share the ColdFusion code with everyone:
<cfsavecontent variable="paragraphs">
<p>This is the first paragraph.</p>
<p>Here's the second paragraph.</p>
<p>And finally, the third paragraph.</p>
</cfsavecontent>
<cfset request.firstParagraph = findNoCase("</p>",trim(paragraphs)) />
<cfif request.firstParagraph gt 0>
<cfset request.firstParagraph = request.firstParagraph+3 />
<cfset request.newsExtract = left(trim(paragraphs),request.firstParagraph) />
<cfelse>
<cfset request.newsExtract = trim(paragraphs) />
</cfif>
<textarea id="newsExtract" name="newsExtract" cols="40" rows="5">
<cfoutput>#request.newsExtract#</cfoutput>
</textarea>
I hope that others find this useful.
Update: 07 December 2006
I have now turned this into a nifty function:
<cfscript>
function firstParagraph(str)
{
str = trim(str);
endTag = findNoCase("</p>", str);
if (endTag gt 0)
{
endTag = endTag + 3;
extract = left(str, endTag);
}
else
{
extract = str;
}
return extract;
}
</cfscript>
This should make using the code even easier.
Update: 08 December 2006
This function is now available on CFLib.org!
Print Styles Not Working In Firefox?
I’ve just recently update my freelance website design website and whilst updating the website I decided to incorporate a print stylesheet. All was working as it should in Internet Explorer, but for some reason Firefox was ignoring the print stylesheet. A little Googleing revealed that if you have titles assigned to the link tag calling the print stylesheet then Firefox ignores it.
Not sure if this is a bug, but it’s worth knowing when creating print styles (which you should be doing).
FlexiCrete Refresh
Yesterday I relaunched the FlexiCrete website. This is a website for a company in South Africa that makes easy-to-use prefabricated paving slabs / stones.

It’s the first website I’ve done in years that uses classic asp, so it was a matter of going back to the books to figure out the database code etc. I’m happy with the outcome.
The website also uses Slideshow Pro for the gallery section.
Why not go have a look?
About
Neil Merton is a South African born web professional currently employed by the Servelogic. These are his thoughts and memories.
Recent Posts
- Twitter Updates for 2008-02-06
- Twitter Updates for 2008-02-03
- Twitter Updates for 2008-02-02
- Website Updated to 2.3.2
- Web2.0* Version 1.7.0 Available
- Web2.0* Theme Gets It’s Own Website
- Happy Festive Greetings
- Web2.0* Version 1.6.0 Available
- Web2.0* and Wordpress 2.3
- Wordpress Unable to use .htaccess
Categories
Archives
- February 2008
- January 2008
- December 2007
- October 2007
- August 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005