Solved

URGENT request to remove unwanted line feed after expansion of variable

Posted on 2012-03-13
3
270 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 15

Expert Comment

by:myselfrandhawa
ID: 37718768
remove paragraphformat and it will display just rightafter its ending
0
 
LVL 24

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now