I knew I wasn't fully awake - I forgot to implement the append/overwrite 
functionality.

Below is an updated version of the first function that allows you to overwrite 
rel, rather than appending onto it.
(You need to update function call in second function to actually turn this on.)

Not entirely happy with how I've done the overwriting, but it works with the 
examples I tried.


<cffunction name="setHyperlinkRel" returntype="String" output="false">
        <cfargument name="LinkCode"  type="String"/>
        <cfargument name="RelValue"  type="String"/>
        <cfargument name="Append"    type="Boolean" default="true"/>
        <cfargument name="Delimiter" type="String"  default=","/>

        <cfset var Head = ListFirst(Arguments.LinkCode,'>')/>
        <cfset var Tail = ListRest(Arguments.LinkCode,'>')/>

        <cfset var RelAttr = rematch( 
'(?ims)\brel=(?:\S+|([''"]).*?)(?=\1(?:\s|$))' , Head )/>

        <cfif ArrayLen(RelAttr)>
                <cfif Arguments.Append>
                        <cfif NOT find(RelValue,RelAttr[1])>
                                <cfset Head = replace
                                        ( Head
                                        , RelAttr[1]
                                        , ListAppend( RelAttr[1] , 
Arguments.RelValue , Arguments.Delimiter )
                                        )/>
                        </cfif>
                <cfelse>
                        <cfset Head = rereplace
                                ( Head
                                , RelAttr[1] & '[''"]?'
                                , 'rel="#Arguments.RelValue#"'
                                )/>
                </cfif>
        <cfelse>
                <cfset Head = Head & ' rel="#Arguments.RelValue#"' />
        </cfif>

        <cfreturn Head & '>' & Tail />
</cffunction>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317965
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to