Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Overview

This is a basic search form which enables you to place a search option for dmNews, you can build it further as required.

The searchform.cfc custom type file

The searchform.cfc custom type file is placed in /packages/types/ in your project or plugin.

searchform.cfc
<!---

Copyright 2010:

Author: Marco van den Oever
Company: MVDO-WSO
Website: http://www.webserviceonline.biz
Email: marco@webserviceonline.biz

License: 

This software is licensed under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
For a copy of the GNU General Public License check the license folder or see <http://www.gnu.org/licenses/>.

Description:

Simple Searchform for dmNews.

Created: 30/05/10

Tested on CF9, FC6.0

--->
<cfcomponent displayname="Search form" hint="Enables display of search form" extends="farcry.core.packages.rules.rules" output="false">
<cfproperty ftFieldset="Search Field" name="searchfield" type="string" fttype="string" default="" ftshowlabel="false" hint="Search Field." ftValidation="required" bSave="false" />
</cfcomponent>

The displaySearchform.cfm webskin file

The displaySearchform.cfm webskin file is placed in /webskin/dmNews/ in your project or plugin.

displaySearchform.cfm

<cfsetting enablecfoutputonly="true" />
<!---

Copyright 2010:

Author: Marco van den Oever
Company: MVDO-WSO
Website: http://www.webserviceonline.biz
Email: marco@webserviceonline.biz

License: 

This software is licensed under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
For a copy of the GNU General Public License check the license folder or see <http://www.gnu.org/licenses/>.

Description:

Simple Searchform for dmNews.

Created: 30/05/10

Tested on CF9, FC6.0

--->

<cfimport taglib="/farcry/core/tags/formtools/" prefix="ft" />
<cfimport taglib="/farcry/core/tags/webskin/" prefix="skin" />
<cfoutput>
  <!-- Start of Search Form Results -->
  <!--- perform action when someone searches --->
  <ft:processform action="search">
    <ft:processFormObjects typename="searchform">
      <!--- get search results --->
      <cfset obj = createObject('component','farcry.plugins.cms.packages.types.dmNews') />
      <cfset props.whereclause = "objectid=objectid AND title LIKE '%#stproperties.searchfield#%' OR Body LIKE '%#stproperties.searchfield#%' OR Teaser LIKE '%#stproperties.searchfield#%'">
      <cfset results = obj.getMultipleByQuery(argumentCollection=props) />
      <cfset searchquery = stproperties.searchfield />
    </ft:processformobjects>
  </ft:processform>
  <!-- End of Search Form Results -->
  <!-- Start of Search Form -->
  <div id="searchform">
    <h2>Search</h2>
    <ft:form css="style.css">
      <ft:object typename="searchform" lFields="searchfield" />
      <ft:farcryButtonPanel>
        <ft:button value="search" />
        <cfif not isdefined('results')>
          No Results
        </cfif>
        <cfif isdefined('results.recordcount')>
          <cfif results.recordcount gt 1>
            #results.recordcount# Results:<br />
            <cfelseif results.recordcount eq 1>
            #results.recordcount# Results:<br />
            <cfelse>
            No Results
          </cfif>
          <br />
          <cfloop query="results">
            <skin:buildLink type="dmNews" objectid="#results.objectid#">#results.title#</skin:buildLink>
            <br />
          </cfloop>
        </cfif>
      </ft:farcryButtonPanel>
    </ft:form>
  </div>
  <!-- End of Search Form -->
</cfoutput>
<cfsetting enablecfoutputonly="false" />

  • No labels