BlogCFC: Removing lastXDays feature
In a previous entry I showed you how could change the default value for number of days to show entries. Well after hearing others thoughts about this, especially Charlie Arehart, this feature really does not make much sense and from everything I read Ray agrees. The reason this feature does not make much sense is because there is already a feature to display last x entries. There is no reason to go any further than this. Let us say that you are a blogger who posts entries 5 times a day or someone who posts 5 times a month, using the last x entries feature will work for both of them. This will also help cut down on going to blog and seeing the dreaded "Sorry there are no blog entries".
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.
<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.
<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.
<cfset params.lastXDays = 0>
<cfset url.mode = "">
