Solved

URGENT request to remove unwanted line feed after expansion of variable

Posted on 2012-03-13
3
271 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: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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 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

17 Experts available now in Live!

Get 1:1 Help Now