Christian sent me a question last week that I thought would be an excellent blog entry. How do you hide certain content from Verity searches? He has a set of content that he wants to hide from users who are not logged in. Or conversely, the total body of content available is limited to anonymous (non-logged in) users. How can you handle this in Verity?

As I discussed in my presentation last week, Verity supports categories when indexing and searching content. Since we only allow a sub-set of content for anonymous users, you could simply use the category feature to mark content available for them. In other words - content that is not protected will have a category of "Public" (or whatever makes sense to you). When searching, your code can do something like so (and the following is code I'm typing from scratch, so please forgive any typos):

<cfif not isAuthenticated()>
<cfset category = "Public">
<cfelse>
<cfset category = "">
</cfif>

<cfsearch collection="mystuff" criteria="#form.searchTerms#" category="#category#">

Notice how we pass in a blank category if the user is authenticated. This basically means we have no filter for authenticated users.

So - this leads to an interesting side discussion. Imagine you display your Verity results in a simple list where each link looks like so:

<a href="articles.cfm?id=#key#">#title#</a><br />

So far so good, right? Now - can someone tell me what code should exist in articles.cfm - assuming the logic we discussed above?