Re: Draft item showing in search results

Jeff Coughlin <[email protected]>
Newsgroups gmane.comp.cms.farcry.devel
Message-ID <8406059371021074536@unknownmsgid>
Well you want to add something like:
and status = 'approved'

Otherwise you'll get pending items as well.

If you want to put in a request to have that changed, then most likely it
will be an argument in the method. I was thinking about asking if I could
modify getRelatedContent() in core to allow filtering by status. It
wouldn't be difficult to do.

--
Jeff Coughlin

On Mar 23, 2013, at 20:40, Marco van den Oever <[email protected]>
wrote:

Thanks Jeff, I couldn't find the search method as I forgot it is part of
the fandango skeleton, and there it was...

<cfcomponent displayname="Simple Search" extends=
"farcry.core.packages.forms.forms"
    fualias="search" hint="A simple search which does a SQL LIKE filter on
dmHTML content.">


    <cffunction name="search" returntype="query">
        <cfargument name="q" type="string" default="">

        <cfset var qResults = "">

        <cfquery name="qResults" datasource="#application.dsn#">
            SELECT objectid, typename, SUM(relevance) AS relevance
            FROM (
                SELECT objectid, 'dmHTML' AS typename, 10 AS relevance FROM
dmHTML WHERE lower(title) LIKE <cfqueryparam cfsqltype="cf_sql_varchar"
value="%#lcase(arguments.q)#%">
                UNION
                <cfif application.dbtype eq "mssql2005">
                    <!--- cast ntext fields as nvarchar for sql server --->
                    SELECT objectid, 'dmHTML' AS typename, 7 AS relevance
FROM dmHTML WHERE lower(CAST(teaser AS nvarchar(max))) LIKE <cfqueryparam
cfsqltype="cf_sql_varchar" value="%#lcase(arguments.q)#%">
                    UNION
                    SELECT objectid, 'dmHTML' AS typename, 5 AS relevance
FROM dmHTML WHERE lower(CAST(body AS nvarchar(max))) LIKE <cfqueryparam
cfsqltype="cf_sql_varchar" value="%#lcase(arguments.q)#%">
                <cfelse>
                    SELECT objectid, 'dmHTML' AS typename, 7 AS relevance
FROM dmHTML WHERE lower(teaser) LIKE <cfqueryparam cfsqltype=
"cf_sql_varchar" value="%#lcase(arguments.q)#%">
                    UNION
                    SELECT objectid, 'dmHTML' AS typename, 5 AS relevance
FROM dmHTML WHERE lower(body) LIKE <cfqueryparam cfsqltype="cf_sql_varchar"
value="%#lcase(arguments.q)#%">
                </cfif>
            ) results
            GROUP BY objectid, typename
            ORDER BY relevance DESC
        </cfquery>

        <cfreturn qResults>
    </cffunction>

</cfcomponent>

I assume I have to add a " AND status NOT LIKE 'draft' " statement?

And if this is correct add this as an improvement ticket to the fandango
skeleton?

Op zaterdag 23 maart 2013 23:59:10 UTC+1 schreef Jeff Coughlin het volgende:
>
> Between the pagination i have custom code.
>
> How do I prevent the draft from showing up?
>
>
> For best performance, you should filter based on the status field in the
> original query.
>
> 1. What version of FarCry are you using?
> 2. What database (and version) are you using?
> 3. What does the search() method (code) look like (that's where the status
> filter will likely go depending on what's in there)?
> 4. I'm assuming you're not using Solr or Verity?  Just querying the DB
> directly?
>
> --
> Jeff Coughlin
>
> On Mar 23, 2013, at 6:50 PM, Marco van den Oever <[email protected]<javascript:>>
> wrote:
>
> Hi all, I see that a draft item is showing up in the search results, I use
> this code:
>
> <cfsetting enablecfoutputonly="true">
> <!--- @@displayname: Simple Search Type Body --->
> <!--- @@author: Justin Carter ([email protected] <javascript:>) --->
>
> <cfimport taglib="/farcry/core/tags/webskin" prefix="skin">
> <cfimport taglib="/farcry/core/tags/admin" prefix="admin" />
>
> <cfparam name="url.q" default="">
>
> <!--- do search --->
> <cfif url.q neq "Zoeken">
> <cfset stLocal.qResults = queryNew("objectid")>
> <cfif len(url.q)>
>     <cfset stLocal.qResults = search(url.q)>
> </cfif>
> </cfif>
>
> <!--- <cfdump var="#stLocal.qResults#"> --->
> <!--- display search message --->
> <cfif url.q neq "Zoeken" and len(url.q) gt 3>
>     <cfoutput>
>         <p>Er <cfif stLocal.qResults.recordCount eq "0">zijn geen
> zoekresultaten<cfelseif stLocal.qResults.recordCount eq "1">is één
> zoekresultaat<cfelse>zijn #stLocal.qResults.recordCount# zoekresultaten
> </cfif> gevonden voor "#url.q#".</p>
>     </cfoutput>
> <cfelse>
>     <cfoutput>
>         <p>Vul een zoekterm (meer dan 3 karakters) in het zoekveld en
> druk op enter of klik op het vergrootglas.</p>
>     </cfoutput>
> </cfif>
>
>
> <!--- <cfdump var="#stLocal.qResults#"><cfabort> --->
>
>
> <!--- display results --->
> <cfif url.q neq "Zoeken" and len(url.q) gt 3>
>
>
> <!--- THIS MEANS PAGINATE --->
>     <skin:pagination query="#stLocal.qResults#" typename="dmNews"
> paginationID="searchNews" recordsPerPage="10" pageLinks="10" r_stobject=
> "data">
>
> Between the pagination i have custom code.
>
> How do I prevent the draft from showing up?
>
> Thanks!
>
> --
> You received this message cos you are subscribed to "farcry-dev" Google
> group.
> To post, email: farcr...-/[email protected] <javascript:>
> To unsubscribe, email: farcry-dev+...-/[email protected] <javascript:>
> For more options: http://groups.google.com/group/farcry-dev
> --------------------------------
> Follow us on Twitter: http://twitter.com/farcry
> ---
> You received this message because you are subscribed to the Google Groups
> "farcry-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to farcry-dev+...-/[email protected] <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
You received this message cos you are subscribed to "farcry-dev" Google
group.
To post, email: farcry-dev-/[email protected]
To unsubscribe, email: farcry-dev+unsubscribe-/[email protected]
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
---
You received this message because you are subscribed to the Google Groups
"farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to farcry-dev+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcry-dev-/[email protected]
To unsubscribe, email: farcry-dev+unsubscribe-/[email protected]
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
--- 
You received this message because you are subscribed to the Google Groups "farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to farcry-dev+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/groups/opt_out.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.