Blogs

Rotating original file for image field in Drupal 7 and dealing with browser cache

While working on new Qwintry.com tasks we needed to provide our operators the interface to rotate uploaded images (and I wanted to rotate the original image file). Surprisingly, I could not find anything like that among d.org modules so I have to come up with my own solution. I was expecting to finish this task by 1 hour, but, as it often happens, the way to right solution took a bit longer.

For the final code scroll down to the end of the post, since now I will be showing some ugly code that you don’t really need :)

Here is the UI for operators:

These links are created in the node—[type].tpl.php in my theme:
Read more »

Building scalable IT system for delivery from US to Russia: Drupal, Symfony2 and Yii2 compared

I was not posting to the blog for a long time, and finally it’s time to share my experience with new project. This post will also cover some badly structured thoughts about PHP frameworks :)

As part of Qwintry team, we’ve built a great b2b product in logistics sphere - Qwintry Logistics - delivery from US to Russia - and it was built on a new PHP framework, so it was a big deal for us - lots of new experience, and it’s great that it was not just experience but a business success as well :)
Read more »

Packt Publishing book - Premium Drupal themes

In 2013 I was invited by Packt Publishing to play a role of technical reviewer in one of their books.
Just got my sample of the book “Premium Drupal Themes” by mail.
It was an honor and nice experience for me, and now I hope to find time and become an author some day :)

Drupal 7 vs Symfony 2: overview after 1 year of Symfony development

We’ve decided to switch to Symfony2 development in July 2012, if I’m not mistaken - after 7 years of (mostly) Drupal development.
There were reasons to do that:

1. Not-too-great experience with high load projects, powered by Drupal 7

Okay, Drupal is good enough until you get a project with big expectations in terms of response time for authenticated users. Nginx proxy, boost and memcached help a lot with anonymous page hits, but things are sometimes not good enough when we talk about authenticated user saving some nodes (1 field = 2 inserts to fields and revisions table, 40 fields - and you get super-slow node saving, at least on non-ssd hosting), using ajax stuff like dynamic forms (Drupal form ajax is not bad, it’s just not super-blazing-fast). Read more »

Storing monetary amounts in db? Use decimals, not floats!

Lot’s of people will be surprised (or shocked, when it happens in production) when they see that mysql can work like this:

Query:

SELECT transaction_id, amount FROM transactions WHERE amount>20.5

Response:

123|20.5

Query:

SELECT transaction_id, amount FROM transactions WHERE amount=20.5

Response:

No rows

So, 20.5 is really greater than 20.5 in sql database. Sometimes. Read more »

Rules won't work properly when run during cron, if you use node access restrictions

I’ve recently created USPS tracking module for Drupal, so Qwintry.com users could get notifications when their international packages change state. I’ve used queue operations to build requests to USPS API by cron, and it seems to work great for our customers, but this story is not about the module.

My plan was to provide rules event “The package [tracking number] changed active state from [old state] to [new state]”. (words in square brackets are Rules arguments). Read more »

Image title as text description for colorbox image formatter (Drupal 7)

When you have core “image” field on your node type and you want to output “title” (or “alt”) of this image just under the image thumbnail as text - you can use image_caption_formatter module for that.
But only in the case when you don’t need another image formatter in place - e.g. Colorbox - because Colorbox provides its own image formatter, and image_caption_formatter module also provides its own image formatter. You obviously can’t use two formatters at the same time. Read more »

Be careful with drupal_get_form() in theme layer

When you create Drupal code for 7 years, it’s easy to mistakenly assume that you know everything regarding such basic things as theme_preprocess_node() and drupal_get_form() functions.
And that is a wrong feeling. Today I’ve discovered that you shouldn’t mix these functions!

The bug description:
I was creating “join” form which was rendered in node.tpl.php of organic group.
When the form was submitted, validation/status messages were shown only after additional page refresh. So, after form submit page was reloading without any messages, and all the messages were appearing on the screen after additional page reload. Read more »

Improving user experience: using Dialogs for profile edit in modal forms

We are now developing big Drupal 7 project where users have profiles with lots of fields.
They also have a node tied to them (“My story”) which is created during registration.

Initially, these were “edit my profile” and “edit my story” links which were leading to a huge forms where user was scared by amount of elements.

And that is the result of UI improvements:
Modal 1

and after clicking “Edit” near “Hobby” item…
Modal 1

So, basically, user has separate small form for photo upload, separate form for about field, and separate form for small details. Read more »

Using Ubercart to sell files: ui improvements and creating file feature programmatically

uc_file module that allows selling files in Ubercart is definitely not perfect in terms of API, but it is a nice piece of functionality.
We’ve just finished creating one e-book store which has product-import feature.
Each product has multiple formats (pdf, epub, rtf) - some products can have pdf+epub, some can have just pdf, others have all three formats attached.

On product page, we wanted to show nice block like this:

Ubercart file downloads

where pdf and doc are just text for regular users, and download links for users that already bought this book.

All the code was created for Drupal 7 + Ubercart 7.x-3.x Read more »

Recent comments

"Thanks for sharing a very informative article. Daily Egypt News http://dailyegypt.net/ "
by Daily Egypt2 hours 21 min ago
"This saved me a lot of time, thanks man "
by Zach Bimson31 weeks 2 days ago
"I worked with Yii2 since it will be started. I used all versions and i want to say it the best framework. DAO and AR patterns wery usefull. Views has a biutifull interface. I glad to meet you with...
by Mirocow34 weeks 23 hours ago
"I think it’s a good idea, but it will require some time to make a module. Have you tried https://github.com/sprytechies/yii2-resque ? It is based on https://github.com/chrisboulton/php-resque...
by Anton Sidashin34 weeks 2 days ago
"Thanks for the comparison write up. It is good to see an up to date comparison of the frameworks. I have been doing Yii for some time and I have enjoyed it because of its close relations to pure...
by slvolz34 weeks 2 days ago
Drupal association member