Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

URGENT request to remove unwanted line feed after expansion of variable

Posted on 2012-03-13
3
Medium Priority
?
279 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

971 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