• Development

    Vim in 10 Minutes

    This week at my local PHP user group we were speaking about IDEs. There were four of us who prepared to speak to attendees. I wasn’t sure what kind of time I’d be allotted, so I didn’t prepare as I usually do. I figured I’d just give an off-the-cuff introduction to some of the niceties of Vim. It didn’t work out as well as I’d hoped.

    About a year ago I did a two-hour Vim talk. I spent a significant amount of time preparing for the talk. The presentation was well-received and, I’d like to think, resulted in a few new Vim users. Why do I mention this? It makes me feel better about the crummy introduction to Vim that I gave last night.

    So I’m just throwing this out there… make sure you have more than 10 minutes if you want to introduce someone to Vim. If you have less than 10 minutes, I suggest grabbing a really messy file and cleaning it up using Vim power. This may be enough to spark some interest. Also you may find it beneficial to just point your audience to a YouTube video of a Vim power user working his/her magic. Vim Tutor is another approach.

  • Development

    Disable Specific States in Ubercart

    Here’s a quick example that illustrates how to remove a few State/Province options from the billing and shipping panes of the Ubercart checkout form, as well as the order edit/create form. Please understand there are other ways to do this (like altering the united_states_840_1.cif file and re-importing). The ​hook_form_alter() method seems less permanent, so I favor it.

  • Development

    Get the Value of the Cheapest Option for an Ubercart Product

    This is just a quick code example. Imaging you have an Ubercart attribute that has several options and you’d like to show an “As low as $X.XX” price on the frontend. Here’s a simple solution. Note that if you wanted the lowest price across ALL attributes you could loop through each attribute too (instead of just looking at attributes[1]).

  • Development

    Lightbox2 Slideshows with Multiple-value Imagefields

    This is a pretty simple example that illustrates the use of Lightbox2’s slideshow feature. In the example, we have an imagefield that allows an unlimited number of images. We only want to render an imagecache version of the first image that, when clicked, will provide a slideshow with the rest of the images in the field. In the example, our field is called “field_product_images”.

    The two files I’m showing are both within the theme for the site.

    There are a few other options for achieving the same end result, but this seemed easier to explain and execute. Depending on your needs, you may need to make this happen at a deeper level (module) or in a field template/function override. If you have another approach, please post a comment!

    Now, one last thing. If you want to render many of these imagelink slideshows on a single page, you’ll need to give each lightshow group a unique name. In this project I had a views block that rendered many of these products in “node” teaser view. So, I added three more lines to my template.php code to append the node ID onto the end of the group name. I added this code just under (outside of) the foreach loop above.