The Situation:
I'm working on a small CMS for a non-profit theatre group using HTMLArea for
a WYSIWYG editor.  I'm storing content blocks in the database and using FB3
and nested layout, calling the content with a URL like <a
href=index.cfm?Fuseaction=Home.DisplayContent&ContentID=1>

The Goal:
I'd like the user to be able to select internal content to link to using a
Select Box in a form.

Although, HTMLArea appears to be a great tool (especially for the price) the
HyperLink interface is difficult, if not impossible to customize--especially
for a Javascript rookie.

Considering this, my idea was to let the user put in a "temporary link" in
HTMLarea WYSIWYG editor, then I would:
1) Parse through the code to find all hyperlinks
2) Create Query of HyperLinks with Columns--LinkID,LinkName (the text and/or
Image the link is wrapped around),LinkCode
2) Present a form with all the links in the submitted content, showing a
Select Box with available Internal Links for each link
3) Parse through the submitted code and replace the temporary links with new
internal links

The Success:
I've been able to do steps 1 & 2, but I may have fried my brain in the
process.

The Problem:
I'm stuck on trying to replace new link with the old link.  Everything I've
tried either doesn't change the code or produces an error.  The problem is
the ReplaceNoCase() Code is not working. I either get syntax errors within
the HTML string, or the string is not replaced.

Any help on solving the problem, or a better way to handle the situation is
greatly appreciated!  If you're ever in Salt Lake City, I'm sure I can get
you a ticket to a great stage performance ;)

Thanks,

Terry

Code for each step follows from when WYSIWYG form is submitted.

act_GetContentLinks.cfm (finds all links and create Query)
-----------------------
<cfset getContentLinks = QueryNew("LinkID,LinkName,LinkCode,ReplaceLink")>
<cfset Continue = 1>
<cfset LinkEnd = 1>
<cfset LinkID = 0>
<!--- Begin loop<br> --->
<cfoutput>

<!--- Loop through String to find links --->
<cfloop condition= "#Continue# EQ 1">
<cfset LinkBegin = FindNoCase("<a href",  attributes.ContentText, LinkEnd)>
<cfif LinkBegin>
        <cfset LinkEnd = FindNoCase("</a>",  attributes.ContentText, LinkBegin)>
        <cfset linkEnd = LinkEnd + 4>
        <cfset linkLength = LinkEnd - LinkBegin>
        <cfset newLink = Mid(attributes.ContentText,LinkBegin,LinkLength)>
                <!--- Get Contents of Link (text or Image) --->
                <cfset nameBegin = FindNoCase(">",  NewLink)+1>
                <cfset nameEnd = FindNoCase("<",NewLink,NameBegin+1)>
                <cfset nameLength = NameEnd-NameBegin>
                <cfset name = Mid(NewLink,NameBegin,NameLength)>


        <cfset LinkID = LinkID+1>
        <cfscript>
                QueryAddRow(GetContentLinks,1) ;
                querySetCell(GetContentLinks,"LinkID",  LinkID) ;
                querySetCell(GetContentLinks, "LinkName", HTMLEditFormat(Name)) ;
                querySetCell(GetContentLinks, "LinkCode", 
HTMLEditFormat(Trim(NewLink))) ;

        </cfscript>

<cfelse>
        <!--- No More Links --->

        <cfset Continue = 0>
</cfif>
</cfloop>
</cfoutput>


dsp_ContentLinkPicker.cfm (Form with all links from above with Select Box of
internal links)
-------------------------
<cfoutput>
<form action="#self#?fuseaction=#XFA.Submit#" method="post"></cfoutput>

<cfoutput query="GetContentLinks">
<table border="1">
<tr>
        <td>
                Link Name
        </td>
        <td>
                #LinkName#
        </td>
</tr>
<tr>
        <td>
                Link Code
        </td>
        <td>
                #LinkCode#
        </td>
        </tr>
<tr>
        <td>
                Change Link To
        </td>
        <td>
                <select name="ReplaceLink#LinkID#">
                        <option value ="#trim(LinkCode)#">Leave As is</option>
                        <Option value ="Replace">Replace With ----></option>
                        <cfloop query="GetAllContent">
                        <cfset tmpName = "<a
href=index.cfm?Fuseaction=Home.DisplayContent&ContentID=" & #ContentID# &
">" & #GetContentLinks.LinkName# & "&lt;/a&gt;">
                        <option value="#tmpName#">#ContentName#
                        </option>
                        </cfloop>
                </select>
        </td>
</tr>


<tr>

        <td height="2" colspan="6" bgcolor="##C0C0C0"></td>
</tr>

</table>


<input type="hidden" name="LinkName#LinkID#" value="#LinkName#">
<input type="hidden" name="LinkCode#LinkID#" value="#trim(LinkCode)#">

</cfoutput>

<cfoutput>
<input type="hidden" name="ContentID" value="#attributes.ContentID#">
<input type="hidden" Name ="ContentName" value="#attributes.ContentName#">
<input type="hidden" name="ContentPageTitle"
value="#attributes.ContentPageTitle#">
<input type="Hidden" name="ContentDescription"
value="#attributes.ContentDescription#">
<input type="Hidden" name="LayoutID" value="#attributes.LayoutID#">
<input type="Hidden" name="ContentStatusID"
value="#attributes.ContentStatusID#">
<input type="hidden" name="ReplaceLinkList"
value="#valuelist(getContentLinks.LinkID)#">

<input type="hidden" name="ContentText"
value="#HTMLEditFormat(attributes.ContentText)#">
<input type="submit" value="Update Links"></cfoutput>
</form>


act_UpdateContentLinks.cfm  (This is where I'm stuck. Still have
debug/testing code)
--------------------------
<cfset oldContent = attributes.contentText>
<cfloop list="#attributes.ReplaceLinkList#" index="LinkID">
        <cfscript>

                FormLinkName = "LinkName"&LinkID ;
                FormLinkCode = Trim("LinkCode"&LinkID) ;
                TestLinkCode = HTMLEditFormat(attributes[FormLinkCode]) ;
                FormReplaceLink = "ReplaceLink"&LinkID ;
                TestReplaceCode = attributes[FormReplaceLink] ;
                newContent = ReplaceNoCase(attributes.ContentText,
attributes[FormLinkCode],attributes[FormReplaceLink]) ;
                test = FindNoCase("yahoo",attributes.ContentText) ;
        </cfscript>



<cfoutput>
                LinkName: #HTMLEditFormat(attributes[FormLinkName])#<br>
                Original Link Code: #HTMLEditFormat(attributes[FormLinkCode])#<br>
                Test Link Code: #TestLinkCode#<br>
                New Link Code: #HTMLEditFormat(attributes[FormReplaceLink])#<br>
                TestReplaceCode: #HTMLEditFormat(TestReplaceCode)#<br>

                Test: #test#<br>


        </cfoutput>

</cfloop>
<cfoutput><br>

#HtmlEditFormat(oldContent)#<br>
<hr><br>

#HtmlEditFormat(newContent)#


</cfoutput>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to