|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Is it possible to replace the @ symbol with an image using only CF?
I want to protect my site a little more from spam harvesters. Is there a way using only ColdFusion to replace the @ symbol with an image of the @ symbol?
I have successfully replaced the @ symbold with &##64; but don't have any luck replacing it with an image. Thanks in advance. |
|
#2
|
|||
|
|||
|
You'll need to provide more information. Do you want CF to scan through a set of static pages and replace all @ characters with an <img> tag? Is the content coming out of a database? Can't give any help until I know more.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Sorry kiteless I guess I should have provided more.
I have dynamic pages whose content is being stored in a database. I have a field in table named email which obviously stores email addresses. When CF serves up the page I would like it to replace all instances of @ in the email addresses on a page with an image. In a perfect situation it would do this domain/system wide with something in the Application.cfm. However, I am not sure if this is possible or not. Thanks in advance. |
|
#4
|
|||
|
|||
|
Two ideas come to mind:
Replace the @ character with the desired image tag text in the SQL select statement. Consult your RDBMS documentation for appropriate instructions and functions to do this (most have a replace() function or something similar) Write conditional code in the output of your data that replaces the @ with the image tag. This could also be done as a user-defined function like formatEmailImage() or something. Hope that helps. |
|
#5
|
||||
|
||||
|
I think kiteless first suggestion is the best option to replace a string from a database field. I don't know how you use the database queries in cold fusion. I normally write stored procedures to perform all the database actions and call that in cold fusion. In this way if we want to change some database table field value or something, we may just change the stored procedure and that reflects every where the query is used in the site.
<< In a perfect situation it would do this domain/system wide with something in the Application.cfm. However, I am not sure if this is possible or not. >> I don't think this is possible from the Application.cfm as you need to use Replace function to change your query variable string. Code:
<cfoutput>#REPLACE(query.fieldname,"@","<img src=""img/path/here"">)#</cfoutput>
__________________
SR - webshiju.com www.lizratechnologies.com "The fear of the LORD is the beginning of knowledge..." |
|
#6
|
|||
|
|||
|
Thanks guys I figured out what my initial problem was. I did not use the double quotes in my img src tag in the Replace function.
Here is what works for me: Code:
#REPLACE(email,"@","<img src=""/images/msc/at.gif"">")# I'm not that familiar with Replace() but can you only replace one substring per function? I would like to include some code to not only replace the @ symbol but also the . with &##46. Is there a way to combine the following replace statement with the one above? Code:
#Replace(email, ".", "&##46;", "All")# |
|
#7
|
|||
|
|||
|
You'll need to look into regular expressions if you want to do multiple replacements. Regex is a massive topic and take a good while to get proficient at, so unless you see a major problem I'd just do it in two separate statements.
|
|
#8
|
|||
|
|||
|
Thanks, I'll look into it. Any suggested places to start for the layman?
|
|
#9
|
|||
|
|||
|
Nothing specific. I'm sure a Google search for "regular expressions" or "regex" will give you more than you could possibly want to see!
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Is it possible to replace the @ symbol with an image using only CF? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|