Solved

Coldfusion page does not display hyperlinks properly

Posted on 2014-09-17
14
173 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
  • 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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 500 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

758 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

21 Experts available now in Live!

Get 1:1 Help Now