Solved

URGENT request to remove unwanted line feed after expansion of variable

Posted on 2012-03-13
3
273 Views
Last Modified: 2012-03-14
<cfquery name="GetStory" datasource="qNEWS">
 select top 1 *
 from bnews
 where ID = '#ID#'
 and online = 1
 order by id desc
</cfquery>

<cfoutput query="GetStory">

<cfset defaultbreakpos = len(GetStory.Story_body)*.6>
<cfif NOT mid(GetStory.story_body, defaultbreakpos, 1) is " ">
  <cfset temppos = refindnocase("[\s]", reverse(left(GetStory.story_body, defaultbreakpos)))>
  <cfset breakpos = defaultbreakpos-temppos+1>
<cfelse>
  <cfset breakpos = defaultbreakpos>
</cfif>
<cfset toptext = left(GetStory.story_body, breakpos)>

#ParagraphFormat(toptext)# <a href="#GetStory.URL_LINK#" target="_blank">Read more</a>

</cfoutput>

Open in new window


The "Read more" line needs to be on the same line as the last line of the story_body. As it is now, it's always moved down one line.

I don't want to remove all the line feeds in the story as they're needed. I only want to remove the last line break, if possible, or do this a different way.

Show me how to do this with my code snippet.
0
Comment
Question by:Qsorb
3 Comments
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 37718768
remove paragraphformat and it will display just rightafter its ending
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 37719731
remember that a paragraph is a block element so results in carriage returns before and after.
so just do the following

change your last lines to this:
<cfset toptext = left(GetStory.story_body, breakpos) & ' <a href="#GetStory.URL_LINK#" target="_blank">Read more</a>'>
#ParagraphFormat(toptext)#

you could even add in some dots like some do like this:
<cfset toptext = left(GetStory.story_body, breakpos) & ' ... <a href="#GetStory.URL_LINK#" target="_blank">Read more</a>'>
#ParagraphFormat(toptext)#

good luck ...
0
 

Author Closing Comment

by:Qsorb
ID: 37723073
myselfrandhawa:  Of course I need the ParagraphFormat so that won't work.

Dgrafx:  That's exactly what I waned. Thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question