BlogCFC: Removing lastXDays feature

Tags: BlogCFC
Word Count: 415
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.
<!--- For default view, limit by date and max entries --->
<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>

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.

Comments

#1 Posted By: Charlie Arehart Posted On: 7/17/07 5:02 AM
Just in case anyone else comes along and wonders what I might have said that Dan's referring to, I just pointed out (in the new cfbloggers discussion list) an entry Dan had done on 7/10 about how those with few posts could change the code in BlogCFC to show more days on the front page. I merely pointed out saying let's avoid the "no blog entries" message. Others chimed in wondering about the value at all, as Dan notes, with that available xentries feature. Just didn't want it to sound like I was lobbying against anything. :-)
#2 Posted By: Dan Vega Posted On: 7/17/07 9:38 AM |
Author Comment
I probably should of mentioned that. Thank you for updating everyone!
#3 Posted By: Phillip Senn Posted On: 7/17/07 9:56 PM
You're the man now dog!
#4 Posted By: Dan Vega Posted On: 7/17/07 10:03 PM |
Author Comment
Ha, thanks Phillip!


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.