Jaci,

See attached, nothing fancy but should work. I took a news rule and replace the references to dmNews to dmHTML, a bit of tweaking on the queries.

Also created a new display method to display the body.

Upload, deploy the rule, then apply the rule ot your page.

Chris.

Jaci Chesnes wrote:
Sounds like a great idea but I don't think I'm ready to tackle creating
custom rules yet.  I've gone throught the tutorials/walkthroughs a
couple times and I always get stuck at the same place.  Maybe I'll
venture into that territory on the next site I roll into FarCry ;-)
<cfcomponent displayname="My dmHTML Rule" 
extends="farcry.farcry_core.packages.rules.rules" hint="">

<cfproperty name="intro" type="string" hint="Intro text for the HTML listing" 
required="no" default="">
<cfproperty name="displayMethod" type="string" hint="Display method to render 
this HTML rule with." required="yes" default="displayteaserbullets">
<cfproperty name="numItems" hint="The number of items to display per page" 
type="numeric" required="true" default="5">
<cfproperty name="numPages" hint="The number of pages of HTML articles to 
display at most" type="numeric" required="true" default="1">
<cfproperty name="bArchive" hint="Display HTML as an archive" type="boolean" 
required="true" default="0">
<cfproperty name="bMatchAllKeywords" hint="Doest the content need to match ALL 
selected keywords" type="boolean" required="false" default="0">
<cfproperty name="metadata" type="string" hint="A list of category ObjectIDs 
that the HTML content is to be drawn from" required="false" default="">

        <cffunction access="public" name="update" output="true">
                <cfargument name="objectID" required="Yes" type="uuid" 
default="">
                <cfargument name="label" required="no" type="string" default="">
                <cfargument name="newform" required="no" type="string" 
default="true">
                <cfimport taglib="/farcry/fourq/tags/" prefix="q4">
                <cfimport taglib="/farcry/farcry_core/tags/navajo/" prefix="nj">
        <cfimport taglib="/farcry/farcry_core/tags/display/" prefix="display">

                <cfparam name="form.bArchive" default="0">
                <cfparam name="form.bMatchAllKeywords" default="0">
                <cfparam name="form.categoryID" default="">

        <cfparam name="isClosed" default="Yes">
        <cfif isDefined("form.categoryid") OR isDefined("form.apply")>
            <cfset isClosed = "No">
        </cfif>

                <cfset stObj = this.getData(arguments.objectid)>

                <cfif isDefined("form.updaterule")>
                        <cfscript>
                                stObj.displayMethod = form.displayMethod;
                                stObj.label = form.label;
                                stObj.intro = form.intro;
                                stObj.numItems = form.numItems;
                                stObj.numPages = form.numPages;
                                stObj.bArchive = form.bArchive;
                                stObj.bMatchAllKeywords = 
form.bMatchAllKeywords;
                                stObj.metadata = form.categoryID; //must add 
metadata tree
                        </cfscript>
                        <q4:contentobjectdata 
typename="#application.rules.ruleMyHTML.rulePath#" stProperties="#stObj#" 
objectID="#stObj.objectID#">
                        <!--- Now assign the metadata --->

                        <cfset message = "Update Successful">
                </cfif>

                <cfif isDefined("message")>
                        <div align="center"><strong>#message#</strong></div>
                </cfif>
                <!--- get the display methods --->
                <nj:listTemplates typename="dmHTML" prefix="displayTeaser" 
r_qMethods="qDisplayTypes">
<cfif newform>
                <form action="" method="POST">
</cfif>
                <table width="100%" align="center" border="0">
                <input type="hidden" name="ruleID" value="#stObj.objectID#">
                <tr>
                                <td align="right">
                                        <b>Title:</b>
                                </td>
                                <td>
                                        <input type="text" name="label" 
value="#stObj.label#" size="40">
                                </td>
                </tr>
                <tr>
                        <td width="20%" colspan="1" align="right">
                        <b>Display method: </b>
                        </td>
                        <td>
                        <select name="displayMethod" size="1" class="field">
                                <cfloop query="qDisplayTypes">
                                        <option value="#methodName#" <cfif 
methodName is stObj.displayMethod>selected</cfif>>#displayName#</option>
                                </cfloop>
                        </select>
                        </td>
                </tr>
                <tr>
                                <td align="right">
                                        <b>Intro:</b>
                                </td>
                                <td>
                                        <textarea rows="5" cols="50" 
name="intro">#stObj.intro#</textarea>
                                </td>
                </tr>
                <tr>
                        <td align="right"><b>Items per page</b></td>
                        <td> <input type="text" name="numItems" 
value="#stObj.numItems#" size="3"></td>
                </tr>
                <tr>
                        <td colspan="2"><b>Display as an Archive?</b> <input 
type="checkbox" name="bArchive" value="1" <cfif 
stObj.bArchive>checked</cfif>></td>
                </tr>
                <tr>
                        <td colspan="2"><b>How many pages would you like in the 
archive at most?</b>  <input type="text" name="numPages" 
value="#stObj.numPages#" size="3"></td>
                </tr>
                </table>

        <br><br>

                <display:OpenLayer width="400" title="Restrict By Categories" 
titleFont="Verdana" titleSize="7.5" isClosed="#isClosed#" border="no">
                <table align="center" border="0">
        <tr>
            <td><b>Does the content need to match ALL the selected 
Keywords?</b> <input type="checkbox" name="bMatchAllKeywords" value="1" <cfif 
stObj.bMatchAllKeywords>checked</cfif>></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
                <tr>
                        <td id="Tree">
                                <cfinvoke  
component="#application.packagepath#.farcry.category" method="displayTree">
                                <cfinvokeargument name="bShowCheckBox" 
value="true">
                                        <cfinvokeargument 
name="lselectedCategories" value="#stObj.metaData#">
                        </cfinvoke>
                        </td>
                </tr>
        </table>
                </display:OpenLayer>
                <div align="center"><input class="normalbttnstyle" 
type="submit" value="go" name="updaterule"></div>
<cfif newform>
                </form>
</cfif>
        </cffunction>

        <cffunction name="getDefaultProperties" returntype="struct" 
access="public">
                <cfscript>
                        stProps=structNew();
                        stProps.objectid = createUUID();
                        stProps.label = '';
                        stProps.displayMethod = 'displayteaserbullet';
                        stProps.numPages = 1;
                        stProps.numItems = 5;
                        stProps.bArchive = 0;
                        stProps.bMatchAllKeywords = 0;
                        stProps.metadata = '';
                </cfscript>
                <cfreturn stProps>
        </cffunction>

        <cffunction access="public" name="execute" output="true">
                <cfargument name="objectID" required="Yes" type="uuid" 
default="">
                <cfargument name="dsn" required="false" type="string" 
default="#application.dsn#">
                <cfparam name="request.mode.lValidStatus" default="approved">
                <cfset stObj = this.getData(arguments.objectid)>

                <cfif application.dbtype eq "mysql">
                        <!--- create temp table for status --->
                        <cfquery datasource="#arguments.dsn#" name="temp">
                                DROP TABLE IF EXISTS tblTemp1
                        </cfquery>
                        <cfquery datasource="#arguments.dsn#" name="temp2">
                                create temporary table `tblTemp1`
                                        (
                                        `Status`  VARCHAR(50) NOT NULL
                                        )
                        </cfquery>
                        <cfloop list="#request.mode.lValidStatus#" index="i">
                                <cfquery datasource="#arguments.dsn#" 
name="temp3">
                                        INSERT INTO tblTemp1 (Status)
                                        VALUES ('#replace(i,"'","","all")#')
                                </cfquery>
                        </cfloop>
                </cfif>
                <!--- If Archive: Get Maximum Rows in New Table --->
                <cfif stObj.bArchive>
                        <cfquery datasource="#arguments.dsn#" 
name="qGetHTMLCount">
                                SELECT objectID
                                FROM #application.dbowner#dmHTML
                        </cfquery>
                        <cfset maximumRows = qGetHTMLCount.recordcount>
                <cfelse>
                        <cfset maximumRows = stObj.numItems>
                </cfif>
                <!--- check if filtering by categories --->
                <cfif NOT trim(len(stObj.metadata)) EQ 0>
                        <!--- show by categories --->
                        <cfswitch expression="#application.dbtype#">
                                <cfcase value="mysql">
                                        <cfif stObj.bMatchAllKeywords>
                                                <!--- must match all categories 
--->
                                                <cfquery 
datasource="#arguments.dsn#" name="qGetHTML" maxrows="#maximumRows#">
                                                        SELECT DISTINCT 
type.objectID, type.publishDate, type.label
                                                            FROM tblTemp1, 
dmHTML type, refCategories refCat1
                                                        <!--- if more than one 
category make join for each --->
                                                        <cfif 
listLen(stObj.metadata) gt 1>
                                                                <cfloop 
from="2" to="#listlen(stObj.metadata)#" index="i">
                                                                    , 
refCategories refCat#i#
                                                                </cfloop>
                                                        </cfif>
                                                        WHERE 1=1
                                                                <!--- loop over 
each category and make sure item has all categories --->
                                                                <cfloop 
from="1" to="#listlen(stObj.metadata)#" index="i">
                                                                        AND 
refCat#i#.categoryID = '#listGetAt(stObj.metadata,i)#'
                                                                        AND 
refCat#i#.objectId = type.objectId
                                                                </cfloop>
                                                                AND type.status 
= tblTemp1.Status
                                                        ORDER BY 
type.datetimecreated DESC, type.label ASC
                                                </cfquery>
                                        <cfelse>
                                                <!--- doesn't need to match all 
categories --->
                                                <cfquery 
datasource="#arguments.dsn#" name="qGetHTML" maxrows="#maximumRows#">
                                                        SELECT DISTINCT 
type.objectID, type.publishDate, type.label
                                                        FROM tblTemp1, 
refCategories refCat, dmHTML type
                                                        WHERE refCat.objectID = 
type.objectID
                                                                AND 
refCat.categoryID IN ('#ListChangeDelims(stObj.metadata,"','",",")#')
                                                                AND type.status 
= tblTemp1.Status
                                                        ORDER BY 
type.datetimecreated DESC, type.label ASC
                                                </cfquery>
                                        </cfif>
                                </cfcase>

                                <cfdefaultcase>
                                        <cfif stObj.bMatchAllKeywords>
                                                <!--- must match all categories 
--->
                                                <cfquery 
datasource="#arguments.dsn#" name="qGetHTML" maxrows="#maximumRows#">
                                                        SELECT DISTINCT 
type.objectID, type.publishDate, type.label
                                                        FROM refCategories 
refcat1
                                                        <!--- if more than one 
category make join for each --->
                                                        <cfif 
listLen(stObj.metadata) gt 1>
                                                                <cfloop 
from="2" to="#listlen(stObj.metadata)#" index="i">
                                                                        inner 
join refcategories refcat#i# on refcat#i-1#.objectid = refcat#i#.objectid
                                                                </cfloop>
                                                        </cfif>
                                                        JOIN dmHTML type ON 
refcat1.objectID = type.objectID
                                                        WHERE 1=1
                                                                <!--- loop over 
each category and make sure item has all categories --->
                                                                <cfloop 
from="1" to="#listlen(stObj.metadata)#" index="i">
                                                                        AND 
refCat#i#.categoryID = '#listGetAt(stObj.metadata,i)#'
                                                                </cfloop>
                                                                AND type.status 
IN ('#ListChangeDelims(request.mode.lValidStatus,"','",",")#')
                                                        ORDER BY 
type.datetimecreated DESC, type.label ASC
                                                </cfquery>
                                        <cfelse>
                                                <!--- doesn't need to match all 
categories --->
                                                <cfquery 
datasource="#arguments.dsn#" name="qGetHTML" maxrows="#maximumRows#">
                                                        SELECT DISTINCT 
type.objectID, type.publishDate, type.label
                                                        FROM refObjects refObj
                                                        JOIN refCategories 
refCat ON refObj.objectID = refCat.objectID
                                                        JOIN dmHTML type ON 
refObj.objectID = type.objectID
                                                        WHERE refObj.typename = 
'dmHTML'
                                                                AND 
refCat.categoryID IN ('#ListChangeDelims(stObj.metadata,"','",",")#')
                                                                AND type.status 
IN ('#ListChangeDelims(request.mode.lValidStatus,"','",",")#')
                                                        ORDER BY 
type.datetimecreated DESC, type.label ASC
                                                </cfquery>
                                        </cfif>
                                </cfdefaultcase>
                        </cfswitch>
                <cfelse>
                        <!--- don't filter on categories --->
                        <cfswitch expression="#application.dbtype#">
                                <cfcase value="mysql">
                                        <cfquery datasource="#arguments.dsn#" 
name="qGetHTML" maxrows="#maximumRows#">
                                                SELECT *
                                                FROM 
#application.dbowner#dmHTML HTML, tblTemp1
                                                WHERE HTML.status = 
tblTemp1.Status
                                                ORDER BY datetimecreated DESC
                                        </cfquery>
                                </cfcase>

                                <cfdefaultcase>
                                        <cfquery datasource="#arguments.dsn#" 
name="qGetHTML" maxrows="#maximumRows#">
                                                SELECT *
                                                FROM #application.dbowner#dmHTML
                                                WHERE status IN 
('#ListChangeDelims(request.mode.lValidStatus,"','",",")#')
                                                        AND SiteID = 
'#request.multisite.currentSiteRootID#'
                                                ORDER BY datetimecreated DESC
                                        </cfquery>
                                </cfdefaultcase>
                        </cfswitch>
                </cfif>

                <cfif NOT stObj.bArchive>
                        <cfif len(trim(stObj.intro)) AND qGetHTML.recordCount>
                                <cfset tmp = 
arrayAppend(request.aInvocations,stObj.intro)>
                        </cfif>
                        <cfoutput query="qGetHTML">
                                <cfscript>
                                        stInvoke = structNew();
                                        stInvoke.objectID = qGetHTML.objectID;
                                        stInvoke.typename = 
application.types.dmHTML.typePath;
                                        stInvoke.method = stObj.displayMethod;
                                        
arrayAppend(request.aInvocations,stInvoke);
                                </cfscript>
                        </cfoutput>
                <cfelse>
                        <cfparam name="url.pgno" default="1">
                        <!--- Get Number of Pages --->
                        <cfset iNumberOfPages = Ceiling(qGetHTML.recordcount / 
stobj.numitems)>
                        <!--- Check URL.pageno --->
                        <cfif url.pgno GT iNumberOfPages OR url.pgno GT 
stobj.numpages>
                                <cfset url.pgno = 1>
                        </cfif>

                        <!--- Check Number of Pages --->
                        <cfif iNumberOfPages GT stobj.numpages>
                                <cfset iNumberOfPages = stobj.numpages>
                        </cfif>
                        <!--- Get Query Start and End Numbers --->
                        <cfset startrow = (url.pgno - 1) * stobj.numitems + 1>
                        <cfset endrow = min(startrow + stobj.numitems - 1, 
qGetHTML.recordcount)>

                        <!--- Output Page Numbers --->
                        <cfif iNumberOfPages GT 1>
                                <cfoutput>
                                <div align="center" class="HTMLArchive">
                                <cfif url.pgno NEQ 1>
                                        <a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#(url.pgno-1)#">Previous
 Page</a>&nbsp;&nbsp;
                                </cfif>
                                <cfloop index="i" from="1" 
to="#iNumberOfPages#">
                                <cfif i NEQ url.pgno><a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#i#"></cfif>#i#<cfif
 i NEQ url.pgno></a></cfif>
                                </cfloop>
                                <cfif url.pgno NEQ iNumberOfPages>
                                        &nbsp;&nbsp;<a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#(url.pgno+1)#">Next
 Page</a>
                                </cfif>
                                </div>
                                <br>
                                </cfoutput>
                        </cfif>

                        <!--- Loop Through HTML and Display --->
                        <cfset o = createObject("component", 
application.types.dmHTML.typePath)>
                        <cfloop query="qGetHTML" startrow="#startrow#" 
endrow="#endrow#">
                                <cfscript>
                                        o.getDisplay(qGetHTML.ObjectID, 
stObj.displayMethod);
                                </cfscript>
                        </cfloop>

                        <!--- Output Page Numbers --->
                        <cfif iNumberOfPages GT 1>
                                <cfoutput>
                                <br>
                                <div align="center" class="HTMLArchive">
                                <cfif url.pgno NEQ 1>
                                        <a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#(url.pgno-1)#">Previous
 Page</a>&nbsp;&nbsp;
                                </cfif>
                                <cfloop index="i" from="1" 
to="#iNumberOfPages#">
                                <cfif i NEQ url.pgno><a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#i#"></cfif>#i#<cfif
 i NEQ url.pgno></a></cfif>
                                </cfloop>
                                <cfif url.pgno NEQ iNumberOfPages>
                                        &nbsp;&nbsp;<a class="HTMLArchive" 
href="#Application.URL.conjurer#?objectID=#url.objectID#&pgno=#(url.pgno+1)#">Next
 Page</a>
                                </cfif>
                                </div>
                                </cfoutput>
                        </cfif>

                </cfif>

        </cffunction>

</cfcomponent>
<cfsetting enablecfoutputonly="yes">
<!--- @@displayname: The Body --->
<cfoutput>#stObj.body# </cfoutput>
<cfsetting enablecfoutputonly="no">

---
You are currently subscribed to farcry-dev as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to