Solved

URGENT request to remove unwanted line feed after expansion of variable

Posted on 2012-03-13
3
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

691 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