Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Coldfusion page does not display hyperlinks properly

Posted on 2014-09-17
14
Medium Priority
?
194 Views
Last Modified: 2014-10-02
i am trying to fix an issue with a certain Coldfusion generated PAGE. In the "How to Apply" section of the page there is meant to be included a URL for a certain website, however the page shows only the first part of the URL in clickable hyperlink format, and everything after the / is shown as plain text. Can you please suggest a solution ?

Please note that these are extracted from the database and displayed dynamically in web pages.

please check this image for how it looks in the database :

image

I have been able to find the specific bit responsible of generating the section, but i don't know what to change there,  if i can get any help on that, that would be greatly appreciated!


<div class="display-item last">
			<div id="how-to-apply">
				<h2>How to apply</h2>
				<p>#formatWithLinks(Arguments.data.ApplicationProcedure)#</p>
				<dl>
					<dt>Closing date</dt>
						<cfif Arguments.data.HasClosingDate>
						<dd>#DateFormat(Arguments.data.ClosingDate, "D MMMM YYYY")#</dd>
						<cfelse>
						<dd>None: ongoing recruitment</dd>
						</cfif>
				</dl>
			</div>
		</div> 

Open in new window


thank you
0
Comment
Question by:JayWeb
[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
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 40330487
You'll need to post your formatWithLinks function.
Also post  a record from the database - raw code direct from the database - only the column(s) that is fed into the formatWithLinks function.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40331388
Tip, CF questions attract more attention when you use the CF topic:
http://www.experts-exchange.com/Programming/Languages/Scripting/Cold_Fusion_Markup_Language/
0
 

Author Comment

by:JayWeb
ID: 40350923
my colleague managed to solve the issue, and i was trying to know from him how he solved it, but all he sent me was that line of code: output = REReplaceNoCase(output,"(\bhttp://[a-z0-9\.\-_:~@##%&/?+=]+)", "<a href=""\1"">\1</a>", "all");  if someone can suggest where this have probably gone that would be great so we can answer and close the question
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 
LVL 52

Expert Comment

by:_agx_
ID: 40351302
>> if someone can suggest where this have probably gone that would
>> be great so we can answer and close the question

Not sure I understand what you mean. Are you asking for additional help OR posting the solution? :)

If you need further help, please post the original code for the formatWithLinks function as dgrafx requested. Then someone can help you adjust it.

Otherwise, you can accept your own response as "the answer".  However, for it to be useful to others, you should include the original code as well.
0
 

Author Comment

by:JayWeb
ID: 40351708
agx, what i mean is if someone can tell me where this expression goes because i wasn't able to find out where it should be included.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40351944
Sure. I'm not sure if you saw the edit to my comment above:

...please post the original code for the formatWithLinks function as dgrafx requested. Then someone can help you adjust it
0
 

Author Comment

by:JayWeb
ID: 40352096
I don't seem to be able to edit the question that's the problem!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40352163
In EE, you can't edit a post after someone else has responded.  

Just post the code as a new comment instead.
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 40354504
You don't need help from more experts, you have the best already helping you.   All you need to do is post the code as they have asked.   How can we help you without seeing the code?
0
 

Author Comment

by:JayWeb
ID: 40354535
Thank you very much for the attention and trying to help. the problem is i haven't been able to locate the files where user located functions are located. if someone can suggest a specific location that i can check that would be greate. otherwise , i can select any answer and close the question.
many thanks
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 40354557
Ok, let's see..   the code you posted at the top, is that in a .cfm file or a .cfc file?

If it's in a .cfc file, you can search the file for the function.   If it's not there, check the first line of the code <cfcomponent for the word expand and see if there is a name in there.  That would be another file to check.

If it's a .cfm file, check the file itself, look in any file mentioned in a CFINCLUDE,  you can also check the application.cfm file (if there is one in the root).

You can also try a search of all files.
0
 

Author Comment

by:JayWeb
ID: 40354680
Hi gdemaria, thank you very much for your suggestions, I tried looking for the locations you mentioned, but no luck there, please look at the complete jobsearch project i have, maybe you can provide further help if you have a complete idea about the structure, the file listing.cfm which the bit at the top is  from, is located in view/modules. please have a look and let me know your thoughts.,

many thanks
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 40355202
The function is located in your view.cfc file in the top folder, for everyone, here is the function code:

	<cffunction name="formatWithLinks" output="false" returntype="string">
		<cfargument name="input" />
		<cfscript>
			var output = Arguments.input;
			/*var httpREWithProtocol = "(?x)
					(
						((https|http):\/\/)		## protocol
						(
							[a-zA-Z]{1}			
							([\w-]+\.)+
							([a-zA-Z]{2,})		## top level domain
						)						## domain name
						(:[\d]{1,5})?			## port number
						((/?\w+/)+|/?)
						(\w+\.[\w]{3,4})?
						((\?\w+=\w+)?
						(&\w+=\w+)*)?
					)";*/
			var httpREWithoutProtocol = "(?x)
					(\s)						## Space requirement here means this won't match beginning of string
					(
						(
							[a-zA-Z]{1}			
							([\w-]+\.)+
							([a-zA-Z]{2,})		## top level domain
						)						## domain name
						(:[\d]{1,5})?			## port number
						((/?\w+/)+|/?)
						(\w+\.[\w]{3,4})?
						((\?\w+=\w+)?
						(&\w+=\w+)*)?
					)";
			var httpREWithoutProtocolBeginningOfString = "(?x)
					^							## Match string here; I don't like doing it this way, but at least it works
					(
						(
							[a-zA-Z]{1}			
							([\w-]+\.)+
							([a-zA-Z]{2,})		## top level domain
						)						## domain name
						(:[\d]{1,5})?			## port number
						((/?\w+/)+|/?)
						(\w+\.[\w]{3,4})?
						((\?\w+=\w+)?
						(&\w+=\w+)*)?
					)";
			var emailRE = "(?x)
					(
						[\S]+@						## user
						[a-zA-Z]{1}				
						([\w-]+\.)+
						([a-zA-Z]{2,})
					)";
			output = REReplace(output, "<[^>]*>", "", "all");
			output = XMLFormat(output);
			//output = REReplace(output, httpREWithProtocol, "<a href=""\1"">\1</a>", "all");
			 output = REReplaceNoCase(output,"(\bhttp://[a-z0-9\.\-_:~@##%&/?+=]+)", "<a href=""\1"">\1</a>", "all");
			output = REReplace(output, httpREWithoutProtocol, "\1<a href=""http://\2"">\2</a>", "all");
			output = REReplace(output, httpREWithoutProtocolBeginningOfString, "<a href=""http://\1"">\1</a>", "all");
			output = REReplace(output, emailRE, "<a href=""mailto:\1"">\1</a>", "all");
			return output;
		</cfscript>
	</cffunction>

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

688 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