[thelist] Tricking the Search Engines

.jeff jeff at members.evolt.org
Fri Mar 8 13:21:01 CST 2002


aaron,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Aaron Johnson
>
> > i'd like to reiterate what morgan already said -- ew.
>
> -- he asked how he could get his website to treat .html
> as .cfm as .asp.  As far as I know, the only way to do
> that is to have cf or asp parse the .htm file ASSUMING
> that he already has all these pages created.  If not,
> your solution rocks!
>
> BTW I didn't say that would give him great performance,
> I was simply answering his questions...
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

agreed.  i was only making a mention of the performance issues and possible
alternate solutions for the edification of anyone interested.  i wasn't
trying to downplay the answer you brought to the table.

<tip type="ColdFusion" author=".jeff">

have a list in coldfusion that's got some duplicate entries?  if you're not
concerned about what order of the elements in the cleansed list or the case
of the individual list elements, then try this:

  <cfscript>
    myList = '1,2,3,2,4,5,2,6,7,3,8,9,1,0';
    myArray = ListToArray(myList);
    myStruct = StructNew();
    for(i = 1; i LTE ArrayLen(myArray); i = i + 1)
      myStruct[myArray[i]] = '';
    myList = StructKeyList(myStruct);
  </cfscript>

if you're concerned about the order or the case of the individual list
elements, then try this:

  <cfscript>
    myList = '1,2,3,2,4,5,2,6,7,3,8,9,1,0';
    myArray = ListToArray(myList);
    myNewList = '';
    for(i = 1; i LTE ArrayLen(myArray); i = i + 1)
    {
      if(NOT ListFind(myNewList, myArray[i]))
        myNewList = ListAppend(myNewList, myArray[i]);
    }
    myList = myNewList;
  </cfscript>

this one is about half again slower, but necessary to maintain case and
order.

alternately, here's a udf to accomplish the same thing (case-sensitive):

  <cfscript>
    function ListDeleteDuplicates(list)
    {
      var i = 1;
      var delimiters = ',';
      var returnValue = '';
      if(ArrayLen(arguments) GTE 2)
        delimiters = arguments[2];
      list = ListToArray(list, delimiters);
      for(i = 1; i LTE ArrayLen(list); i = i + 1)
        if(NOT ListFind(returnValue, list[i], delimiters))
          returnValue = ListAppend(returnValue, list[i], delimiters);
      return returnValue;
    }
  </cfscript>

and the same thing, but case-insensitive:

  <cfscript>
    function ListDeleteDuplicatesNoCase(list)
    {
      var i = 1;
      var delimiters = ',';
      var returnValue = '';
      if(ArrayLen(arguments) GTE 2)
        delimiters = arguments[2];
      list = ListToArray(list, delimiters);
      for(i = 1; i LTE ArrayLen(list); i = i + 1)
        if(NOT ListFindNoCase(returnValue, list[i], delimiters))
          returnValue = ListAppend(returnValue, list[i], delimiters);
      return returnValue;
    }
  </cfscript>

</tip>

enjoy,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list