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.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--- For default view, limit by date and max entries --->
<cfset params.lastXDays = 30>
<cfset url.mode = "">
1<!--- For default view, limit by date and max entries --->
2 <cfset params.lastXDays = 30>
3 <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.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--- 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>
1<!--- If lastXDays is passed, verify X is int between 1 and 365 --->
2 <cfif structKeyExists(arguments.params,"lastXDays")>
3 <cfif not val(arguments.params.lastXDays) or val(arguments.params.lastXDays) lt 1 or val(arguments.params.lastXDays) gt 365>
4 <cfset structDelete(arguments.params,"lastXDays")>
5 <cfelse>
6 <cfset arguments.params.lastXDays = val(arguments.params.lastXDays)>
7 </cfif>
8 </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.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--- For default view, limit by date and max entries --->
<cfset params.lastXDays = 0>
<cfset url.mode = "">
1<!--- For default view, limit by date and max entries --->
2 <cfset params.lastXDays = 0>
3 <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.
This entry was posted on July 16, 2007 at 11:02 PM and has received 3347 views. Comments 4 |
Print this entry.
#1 by Charlie Arehart on 7/17/07 - 5:02 AM
#2 by Dan Vega on 7/17/07 - 9:38 AM
#3 by Phillip Senn on 7/17/07 - 9:56 PM
#4 by Dan Vega on 7/17/07 - 10:03 PM