BlogCFC: Removing lastXDays feature
Monday July 16, 2007 10:02 PM
Word Count: 415
With that being said I would like to remove this feature from blogCFC. Fortunately you may not realize this but its as easy as removing 1 digit from the code. If you goto the tags folder and open the getMode.cfm template you will see the following code towards the bottom.
<!--- For default view, limit by date and max entries --->
<cfset params.lastXDays = 30>
<cfset url.mode = "">
<cfset params.lastXDays = 30>
<cfset url.mode = "">
In the end this is a part of a paramter structure that gets passed to the getEntries() method of the component org.camden.blog.blogcfc. Here is the part of the getEntries method that we are interested in.
<!--- If lastXDays is passed, verify X is int between 1 and 365 --->
<cfif structKeyExists(arguments.params,"lastXDays")>
<cfif not val(arguments.params.lastXDays) or val(arguments.params.lastXDays) lt 1 or val(arguments.params.lastXDays) gt 365>
<cfset structDelete(arguments.params,"lastXDays")>
<cfelse>
<cfset arguments.params.lastXDays = val(arguments.params.lastXDays)>
</cfif>
</cfif>
<cfif structKeyExists(arguments.params,"lastXDays")>
<cfif not val(arguments.params.lastXDays) or val(arguments.params.lastXDays) lt 1 or val(arguments.params.lastXDays) gt 365>
<cfset structDelete(arguments.params,"lastXDays")>
<cfelse>
<cfset arguments.params.lastXDays = val(arguments.params.lastXDays)>
</cfif>
</cfif>
Basically this code is looking for a value between 1 and 365 if it does not find a valid value it deletes the structure key. If the structure key is not there this feature is not used. So how do you remove the feature? Simply go back to the getMode.cfm template and change the lastXDays paramater to 0.
<!--- For default view, limit by date and max entries --->
<cfset params.lastXDays = 0>
<cfset url.mode = "">
And there you have it, even if you write 1 entry per month your home page will display entries based on the last x entries setting in your admin.<cfset params.lastXDays = 0>
<cfset url.mode = "">
