So I am a little late to wishing you my readers a happy new year…so sue me!
With a new year comes big changes as with every year. The biggest for this blog is going to be in the form of a new design. Expect to see something in the next few months. Besides the design I also expect to start blogging more. Even if it isn’t all code related anymore. It could be about anything I decide! That’s why it’s my blog right?
Until then… well I hope to see you back soon!
So we all knew this was coming, I was just slightly surprised to see a post on dZone about it getting leaked out a day early, especially when it says {Don’t Publish}
. So it looks like tomorrow we will be downloading betas to the new kid on the block CFBuilder 2. Can’t wait to see whats in store!
For more information please visit DZone’s post about what features it will include. Pretty nice little overview.
Update:
Unfortunately looks like the post got taken down probably the same day. So here is the updated link (Thanks Henry!) with the cached view of the page. DZone Cache
So I was working on upgrading our site at work to a newer server, as which I can now utilize CF 9 and all of the awesome CFScript stuff that comes with it. Now I am not sure if this came specifically in CF 9 or not, though I do believe this has been possible since CF 8 I may be incorrect so if so please let me know in the comments.
Anyways, back to the image manipulation. It really is rather simple, it simply requires that an image it loaded, scaled or resized and then saved. For my purposes we scaled our images to fit certain sizes.
image_manip = imageRead("imageDir/image.jpg");
imageScaleToFit(image_manip, "50", "50", "mediumQuality");
imageWrite(uploadImage, "uploadDir/newimagename.jpg", "true");
So the above simply reads the image in, than scales it to fit, with mediumQuality, and saves it as a new image. Another quick and easy feature to Coldfusion that you have got to love!
I took a class last semester on Python and was fairly impressed by its simplicity. I then got to thinking, I wonder if some features that I like are in CF. Sure enough, I found one of my favorites, setting multiple variables with the same value at the same time. I know it’s a very little feature, but go with me! I think it could be very useful. Here is an example of it being used. Also worth a note, I believe after looking into it this is CF 9 only.
weeks = end = come = on = now();
Ok it may not seem like much, but to me it is awesome! Coldfusion making the world a better place
. Anyways basically this sets all 4 variables, week, end, come and on, to the current date and time on the server. For some more insight on valid uses of this neat feature. CF 9 Doc’s
So I was looking for a way to select the most popular products from a database that I am using for my companies website. When I first approached this I thought it would be more work than it turned out to be and was really surprised to see how simple the SQL statement turned out to be. I found this on daniweb where someone else had asked a question about this exact problem. Here is the query.
SELECT productid, SUM(quantity) AS total FROM orderdetail GROUP BY productid ORDER BY total DESC LIMIT 10
What this will do is simply select the productid, and then using a built in SQL function called SUM() take all the quantity fields for that product and add them together giving me a field called total. I then tell it to group results by the productid so I can get the total for each productID. I decided to get only the top 10 results in descending order. So I simply set it to ORDER BY the total in DESC fashion, while setting the LIMIT to 10. Pretty cool, and simple!
So I posted this on the old blog and Chris Peters told me about another way of doing this that is new to CFWheels 1.1. Pretty cool stuff I didn’t even know was there. In 1.1 they introduced 2 new view helper functions called contentFor() and includeContent(). What you can do with these is add content to variable name, either through a variable, string, integer etc. Then in the view call includeContent() and it will include the content. An example can be seen below.
<!--- Controller, though it could also be in the view ---> <cfset contentFor(title="| Title Here") /> <!--- Layout view ---> <title>Default Title Here #includeContent(name="title", default="")#</title>
The only thing I would like to see is a way to add a default delimiter so I don’t have to rewrite it in the contentFor() function over and over again. This might be feature creep though as the contentFor and includeContent can be used for much more than that. There may be some way that I don’t know about though, so if you do, please, say so in the comments.
Update
Okay forget the statement above. Here is how you do that, simply put the delimiter in the layout view…done. 8-/ Cannot believe I missed that…oh well
Thanks to Chris Peters for the advice on using WordPress! Get ready because we are about to go on a journey exploring all types of code, and really anything that interests me…so mainly code! Thanks for stopping! Really looking forward to getting to know each and every one of you.
Nathan