How to use jQuery to sort and reorganize your content

Hello! Recently we were tasked with finding ways to re-organize search results on a Drupal page in such a way that we could prioritize, group and sort the results in a coherent way. The simplest way to look at organizing in general, especially content that is dynamically generated, is to either adjust the query that actually produces the results (back-end) OR adjust the results with jQuery (front-end). There are advantages and reasons why one way may be more advantageous over the other. Adjusting the query that produces the results may produce the sorted results quicker however the downside might be that making further adjustments or improvements requires extra overhead since building and executing database queries (for example) requires additional testing, QA and all that sort of stuff. Alternatively, if you sort the content / results on your page with jQuery, it is much more flexible and easier to manipulate the […]

How to speed up drupal : Clean up base64 encoded images

Hello! Recently we experienced a severe slowdown bottleneck with a Drupal site. After some debugging we decided to turn on mysql slow query logging. After watching the logs we noticed that while the content page was loading in Drupal’s administration back-end there was extremely long scrolling of encoded binary data :

The scrolling was endless! Even though the content list view in Drupal paginates after displaying about 40-50 nodes, loading these data blobs for every node caused the page load time to take 2-3 minutes! Sometimes it even just timed out and failed with an error. This behavior would be dependent on the php.ini execution time settings and perhaps php-fpm configuration directives for memory allocation and whatnot. Whats worse, when this was happening, all other actions on the server were impossible to complete. This is because the PHP process spiked to 100% CPU from having to process the large […]

How to export and import field collection data in Drupal

Hello! There are many great tools out there that make importing and exporting content into Drupal nodes very easy. We deal with custom Drupal content often and have extensively used many of the (amazing) tools available, such as node export, views data export and feed import , specifically with the field collection feeds addon. With all of these solutions, we had limited but no success in exporting our custom content + field collection data. Our field collections contained fields that were configured to store multiple values as an array, which may be why. We never tried the tools that didn’t work with different variations of field options in our field collections. They just didn’t work for us. So we looked into how hard it would be to write our own drush command to easily integrate into our code push system (the system through which code and data is propagated from […]

Create self-populating ajax drop-down forms in Drupal with the Form API

Hello! At risk of making the title of this post a mouth full, I thought I’d share some of our experience with interacting with Drupal’s Form API (Specficially Drupal 7.x). There is a lot of documentation on different ways you can interact with the Form API to accomplish a wide range of tasks from collecting information, processing information or building complex search queries. The latter is where we ventured in our most recent work interacting with Drupal’s Form API. We worked on a project where the requirement was to build a drop-down based filtration system where content category choices in the drop-down boxes would auto populate dependent taxonomies based on the relationship of the taxonomies , content fields and content in general. After choosing all the drop-down boxes, the end-user would then be able to click a “Go” button to build a list of results that apply the selected filters. […]

Convert text to an image with Javascript and HTML5

Hello! Working with frameworks like Django and with CMS’ like Drupal and WordPress we come across a wide variety of requirements for manipulating, sanitizing and importing data from all different sources and formats. Recently we had the requirement to take a text field that was defined in a Django model and convert that text string to an image. There are many reasons for this type of requirement. You could argue that this requirement would be the first (of many) steps towards implementing your own custom captcha solution. Well we did some research and found some solutions out there and implemented it our self in Django and we thought we’d share here as well! I’ll go through each of the components necessary to implement this. This type of implementation can very easily be integrated into WordPress or Drupal through a custom module or custom plugin or function perhaps. Additionally you can […]

Drupal Problem : An AJAX HTTP request terminated abnormally

Hello! Recently we had a tricky problem with Drupal 7 and manipulating content. Our content types and content in general for a particular Drupal site has grown significantly. Ajax queries in Drupal Adding and removing content such as images or gallery items requires an Ajax query that polls the database. These queries, once your database grows on a drupal site, can also grow. You might not notice much of a difference (when its working) but it does require more overhead when manipulating data via Drupal’s administration area. When attempting to add or delete an item within a content type , we received this error : When investigating further, we saw this in the DBLog within Drupal : Why Ajax was returning an error Further investigation provided some evidence of this error. What we found was that many different elements , configuration settings or permissions could be causing these types of […]