fvillena
09-06-2006, 08:41 AM
Hi Everyone
Basically I have an ASP page that outputs the content of an article from a database onto a page, the content is in HTML complete with <p> tags and so on and the user can also insert images etc.
My problem is that I want to only display the first two/three paragraphs of the article if a user has not logged in. If I just use Left(article,1000) or similar then it could cut off the content in the middle of an image tag etc.
I've put in code that goes through the content and finds the third closing </p> tag and use that for the position in the left statment which although okay I'm sure problems would arise in a real world scenario where say for some reason an article doesn't have any paragraph tags.
I don't want to strip the HTML tags from the content as I still want the first 3 paragraphs of the article to retain its formatting.
Any ideas would be greatly appreciated.
Basically I have an ASP page that outputs the content of an article from a database onto a page, the content is in HTML complete with <p> tags and so on and the user can also insert images etc.
My problem is that I want to only display the first two/three paragraphs of the article if a user has not logged in. If I just use Left(article,1000) or similar then it could cut off the content in the middle of an image tag etc.
I've put in code that goes through the content and finds the third closing </p> tag and use that for the position in the left statment which although okay I'm sure problems would arise in a real world scenario where say for some reason an article doesn't have any paragraph tags.
I don't want to strip the HTML tags from the content as I still want the first 3 paragraphs of the article to retain its formatting.
Any ideas would be greatly appreciated.