A friend of mine is writing an iOS application which will communicate with a web server. He needed a basic JSON program to test out his code, so I wrote him this:
I need to insert a key/value at a certain position in an associative array. It seems like a common issue. I was surprised to discover there wasn't a straightforward answer. Here is the method I created. If you know of a more efficient method, please let me know in the comments.
A common issue when building a site in Drupal: you've got a $node, $vars['node'], or $form_state['node'] and need to render an image (with image style) from one of the fields. I am building a custom form in this instance, and need to show the first image stored in some loaded nodes.
Update: Dave Reid just added basic field token support to Token. Try the beta4 of Token (http://drupal.org/project/token) before Entity Tokens. I worked out what needed to happen a few weeks ago, and finally wrote it up. I didn't realize there was an update the Token when I posted. Haha! Internet moves quick!
I'm building an interface to simplify the user experience during content creation. Users select options in three <select> fields, then on submit, they are forwarded to the correct content type add node form for the options selected. Some of the values from the original form will be be pre-filled in the new node add form.
To create this new form, I need fields from the content types and user profile. Given a content type, field name, and field instance, this is the code you need to get the Form API renderable array for the field.
Normally I work in Windows or Linux. Currently, I am working on an iMac. Rather than fighting years of muscle memory, I switched the Command and Control keys in the Keyboard preferences. Problem is now Control keys in iTerm don't work. After some research I determined how to send Control characters with both Command and Control.
Note: I know this could use some screenshots. No time right now.
Here is how to make Control-C work in iTerm when Control/Command have been switched:
I need a page on my Drupal 7 project site to display within a jQuery modal dialog box. Adding content to a jQuery dialog is straightforward with the Dialog module. The issue was the dialog box needed to contain the contents of a Panel. Previously I've embeded Views using views_embed_view(), but I've never tried to embed a Panel. A web search wouldn't give me a quick answer, so I worked it out.
If you are new to online video processing, you may be overwelmed with the available information. You or your client just want video on a website. The simpliest option is the use YouTube or some other free video host. Most companies won't like the idea though. They don't want to obviously advertise a separate product or business through their website. Entirely reasonable.
This is a simple example of the use of Views hooks in the template.php file of a theme. It is written for use with Drupal 7 and Views 7.x-3.0-beta3.
In this project, a page contains a View which must display one, two or three results/rows. Each row contains an image and and body text. The final output display must to stay roughly the same size regardless of the amount of content. To make it all fit and allow for custom theming/CSS, I decided to change the Image Style and Row Class depending on the number of results.
Much of the styling and theming a designer specifies in a Drupal design mockup can be easily implemented. Once in a while, you'll run into a request that seems simple, but gets far more involved.