Subscribe to my full feed.
Showing posts with label coldfusion. Show all posts
Showing posts with label coldfusion. Show all posts

Wednesday, July 23, 2008

HowTo: Index a ColdFusion Site for Search with VSpider

So in my studies of learning ColdFusion and working on my first few projects, I came into an issue. I was redeveloping the public website for the company I am currently working for. The previous site was poorly built with little or no code reuse ability and quite a bit of static navigation and content.

I redesigned and developed the entire site. When I finished I entered the coldfusion administrator and re indexed the search collection. I performed a search to test it and was immediately alarmed. My search results were displaying code... I was confused and immediately grabbed my book on ColdFusion to learn that the built in search indexing collection could be prepared two ways, by reading the raw source code and indexing it (which is fine for completely static pages) or by using the search spider that is built in from Verity.

The clear solution is to use the Verity Spider. So this post is dedicated to how I was able to index my dynamically generated site with the Verity Spider.

  1. Make your site available on localhost, even if your site will not stay there. For example, http://localhost/mysite/

  2. Create a text file called mysiteCmds.txt and save it to the verity folder within the ColdFusion directory. For Example, C:\ColdFusion8\verity\mysiteCmds.txt

  3. In this document will be all of your commands for the vspider such as starting point, files to exclude from the index and so on. For Example, mine looks like the following:

    -style c:\ColdFusion8\verity\Data\stylesets\ColdFusionVspider
    -collection c:\ColdFusion8\verity\collections\mysite
    -exclude http://localhost/mysite/admin/*
    -indmimeexclude text/css
    -start http://localhost/mysite/index.cfm
    -cgiok

  4. Then I open up the command prompt (start->run->cmd) and run the following line,
    vspider -cmdfile c:\ColdFusion8\verity\mysiteCmds.txt

  5. Then you need to navigate to the CF Administrator (http://localhost/CFIDE/Administrator/) and add the collection under Verity Collections. Name it the same as you set it in the CmdFile, mysite. Be sure to select English Advanced.

  6. Next you need a search form.

    <_cfform action="search.cfm" method="post" name="submitSearch" ><_INPUT class="btn" type="submit" value="SEARCH" /><_/cfform>

  7. Last, you need to be able to display the results.

    <_cfsearch collection="mysite" name="results" criteria="#searchterm#" type="simple">
    <_cfloop query="results">
    <_cfset score2 = (score * 100)>
    <_span style="font-weight:bold ">#currentRow#. #score2#% : <_a href="#replace(url,"localhost/mysite/","www.mysite.com/")#">
    <_cfif title eq "">
    #replace(url,"localhost/mysite/","www.mysite.com/")#
    <_cfelse>
    #title#
    <_/cfif>
    <_/a><_/span>
    #left(summary, 150)#
    <_/cfloop>

    Remove the underscores, I had to add them so that the code would display.



Resources:

http://www.monkeyflash.com/coldfusion/using-vspider/
http://www.adobe.com/devnet/coldfusion/articles/vspider.html


Chris

Wednesday, June 25, 2008

HowTo: Stop ColdFusion Cookies From Vanishing

I encountered this problem recently in my exploration of ColdFusion where I set cookies within the session start function of the application.cfc to track information about how a user found our site, what browser they are using and their general locale.  Using debugger, I could tell that the cookies set properly when I first entered the site.  Once I navigated away from the first page the cfcookies were dropped or missing.

It was driving me nuts.  I did about 20 minutes worth of research before I found a solution.  Basically if I had not set client cookies to no, ColdFusion would try to automatically handle cookies being set on the users machine and apparently it just causes problems.  So I set this by entering the following line of code into my application.cfc.

< cfset setclientcookies="no" >


After I set that, closed and opened the browser and the cookies worked properly.  Hopefully this helps others who have experienced the same thing as me.

Chris

Tuesday, May 27, 2008

ColdFusion

Well I have been working for a new company now for almost a month. Part of the job requirements were for me to learn how to program web applications using Adobe's ColdFusion. So far I have to say that in just a few weeks I can now develop database driven applications with AJAX components. Not bad.

My initial thoughts were that I would hate programming in ColdFusion. But after building my first mini application and redesigning their commercial website using ColdFusion components, I am quite impressed.

For those of you who are unfamiliar with ColdFusion, it was one of the first application servers to allow developers to provide dynamic content using back end databases. It is very similar to Microsoft's ASP.net, Java Server Pages and PHP. It has a simple syntax that is similar to HTML and provides for ease of use programming. The latest version, version 8, has built in functionality for AJAX or dynamic interaction components, like popup windows, dynamic menus, and pods. Find more information about ColdFusion at wikipedia.

I am mid/senior level programmer using ASP / PHP, so learning ColdFusion has not been much of a challenge, not to mention it has been kind of fun. It is like driving a 10 year old Camry your whole life because of costs and then getting to see what it is like to drive a Cadillac. Not that I am comparing ColdFusion to a Cadillac, but it is nice to use a for profit application server that has quite a bit of built in functionality that does a bunch of work for the developer. But with every tool, there are pros and cons. The biggest con in this instance is the fact that ColdFusion is not cheap.

If you are interested in taking it for a test drive, Adobe has made available a development version of ColdFusion that is free to install and use. You have all the bells and whistles of the full blown version, except it is for development use. I recommend that if you have the resources to go with ColdFusion in a production environment, then you should definitely consider it as an option. It is powerful, easy and robust.