ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 13th, 2004, 11:13 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
how to replace???

ok im making a forum and i dont know where to start with the bb forum code.

how would that be done??

for example:

when someone clicks on a smily it inserts :smily: into the text, how would i convert that into <img src="images/emoticons/smily">

when the post is displayed??

also, for example, when they want to make text bold:
(excuse the spaces)

[ b]this text bold[ /b]


it ends up like:

this text bold

and for example when they want to post images:

[ img]imgurl.jpg[ /img]


any ideas on how that would be done??


i tried using the Replace() function but i didnt seem to get it right???

Reply With Quote
  #2  
Old September 13th, 2004, 11:22 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You can do this with replace() and replaceNoCase(), or look into using regular expressions with reReplace() and reReplaceNoCase(). If you search around on the web you will find tons of regular expression tutorials and examples.
__________________
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

Reply With Quote
  #3  
Old September 13th, 2004, 01:08 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
ok i got the replace() function to work, but my question to you now is, how do i get it to work if i have to replace multiple things in a post??

Reply With Quote
  #4  
Old September 13th, 2004, 01:24 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Use the 'All' argument to the replace() function, which I sure you already know from reading the documentation.

http://livedocs.macromedia.com/cold...8.htm#wp1111342



Again I'll mention what has already been said before, I'm here to help, but for basic questions like this about a function, PLEASE read the docs first!

Last edited by kiteless : September 13th, 2004 at 01:27 PM.

Reply With Quote
  #5  
Old September 13th, 2004, 01:37 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
no no you dont understand, here is an example of my code

#ParagraphFormat(Replace(topiccontent, ":bigsmile:", "<img src=images/emoticons/biggrin.gif>", "all"))#


now you see there how i have only one smily to be replaced, well i got about 15 more different smilys that i want to replace, how would i do that?

Reply With Quote
  #6  
Old September 13th, 2004, 02:11 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
One option would be to create a structure that maps the smiley name to the image. Then loop over the structure and run a replace for each key in the struct. Something like this (pseudocode):

smileyStruct = structNew()
smileyStruct.bigSmile = ''biggrin.gif"

cfloop collection="#smileyStruct#" item="thisSmiley"
set myText = replace( myText, ':#thisSmiley#:', '<img src="images/emoticons/#smileyStruct[thisSmiley]#">', 'All' )
/cfloop

You could also define the mappings in an XML file, read them in, and loop over them that way. Just another approach. Hope that helps.

Reply With Quote
  #7  
Old September 14th, 2004, 08:43 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
ok i made this code, but it still shows the smilies as they were entered into the database :smiley:

my code is below

<cfset smileyStruct=structNew()>
<cfset smileyStruct.angry= "angry.gif">
<cfset smileyStruct.bigsmile= "biggrin.gif">
<cfset smileyStruct.confused= "blink.gif">
<cfset smileyStruct.blush= "blush.gif">
<cfset smileyStruct.whew= "closedeyes.gif">
<cfset smileyStruct.cool= "cool.gif">
<cfset smileyStruct.grin= "dry.gif">
<cfset smileyStruct.exclamation= "excl.gif">
<cfset smileyStruct.happy= "happy.gif">
<cfset smileyStruct.huh= "huh.gif">
<cfset smileyStruct.laugh= "laugh.gif">
<cfset smileyStruct.mad= "mad.gif">
<cfset smileyStruct.ohmy= "ohmy.gif">
<cfset smileyStruct.rolleyes= "rolleyes.gif">
<cfset smileyStruct.sad= "sad.gif">
<cfset smileyStruct.smile= "smile.gif">
<cfset smileyStruct.tongue= "tongue.gif">
<cfset smileyStruct.unsure= "unsure.gif">
<cfset smileyStruct.wink= "wink.gif">

<cfloop collection="#smileyStruct#" item="thisSmiley">
<cfset topiccontent = replace( topiccontent, ":#thisSmiley#:", "<img src=images/emoticons/#smileyStruct[thisSmiley]#>", "All" )>
</cfloop>
#ParagraphFormat(topiccontent)#

Reply With Quote
  #8  
Old September 14th, 2004, 09:33 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
I would probably use replaceNoCase() instead of replace() to handle any case situation.

The key is to confirm that this line of code is working:

<cfset topiccontent = replace( topiccontent, ":#thisSmiley#:", "<img src=images/emoticons/#smileyStruct[thisSmiley]#>", "All" )>


If you replace the varaibles with the values you defined, does it work? Like this:

<cfset topiccontent = replace( topiccontent, ":angry:", "<img src=images/emoticons/angry.gif>", "All" )>

Reply With Quote
  #9  
Old September 14th, 2004, 09:34 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Ah, in fact I can almost guarantee that it is a case problem, as CF treats structure keys as capitals. Try it like this:

<cfloop collection="#smileyStruct#" item="thisSmiley">
<cfset topiccontent = replaceNoCase( topiccontent, ":#thisSmiley#:", "<img src=images/emoticons/#smileyStruct[thisSmiley]#>", "All" )>
</cfloop>

Reply With Quote
  #10  
Old September 14th, 2004, 10:56 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
nope still same

Reply With Quote
  #11  
Old September 14th, 2004, 11:36 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Well I'm not sure what you are doing wrong because this works for me:

<cfset smileyStruct=structNew()>
<cfset smileyStruct.angry= "angry.gif">
<cfset smileyStruct.bigsmile= "biggrin.gif">
<cfset smileyStruct.confused= "blink.gif">
<cfset smileyStruct.blush= "blush.gif">
<cfset smileyStruct.whew= "closedeyes.gif">
<cfset smileyStruct.cool= "cool.gif">
<cfset smileyStruct.grin= "dry.gif">
<cfset smileyStruct.exclamation= "excl.gif">
<cfset smileyStruct.happy= "happy.gif">
<cfset smileyStruct.huh= "huh.gif">
<cfset smileyStruct.laugh= "laugh.gif">
<cfset smileyStruct.mad= "mad.gif">
<cfset smileyStruct.ohmy= "ohmy.gif">
<cfset smileyStruct.rolleyes= "rolleyes.gif">
<cfset smileyStruct.sad= "sad.gif">
<cfset smileyStruct.smile= "smile.gif">
<cfset smileyStruct.tongue= "tongue.gif">
<cfset smileyStruct.unsure= "unsure.gif">
<cfset smileyStruct.wink= "wink.gif">

<cfset topicContent="This is the content. Here is a big smile: :bigsmile: And here is some more text." />

<cfloop collection="#smileyStruct#" item="thisSmiley">
<cfset topiccontent = replaceNoCase( topiccontent, ":#thisSmiley#:", "<img src=images/emoticons/#smileyStruct[thisSmiley]#>", "All" )>
</cfloop>
<cfoutput>
#ParagraphFormat(topiccontent)#
</cfoutput>

Reply With Quote
  #12  
Old September 14th, 2004, 01:17 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
i will email you a copy of my code so you can analize it, cause that works for me too but i dont know what could be causing it not to work in the page...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > how to replace???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump