BTMash

Blob of contradictions

planet drupal

But I just want one field! Using field_attach_load()

Fri, 04/13/2012 - 12:00 -- btmash

Yesterday evening, I was working with a client on their site who are doing some interesting things with one of their custom search pages. They send ajax requests to the backend to get 2 types of values for their user:

  • A count on the total number of a node type X that matched the criteria
  • A count on the total number of another node type Y that is referenced in node type X (Y can be referenced multiple times by various X but for this, we just want to get back that value.

Instead of opting to go with straight database queries to get the data, they were using the EntityFieldQuery manner to get the initial list of X since they were using fields. Its not quite as fast, but its a much more flexible approach (and if they opt to change their field storage in the future to something like MongoDB, they can have something really fast without having to change a single line of code!). The one problem with EntityFieldQuery, however, is that it will only return back a listing of entity IDs. Meaning that if we want to get other pieces of data, we have to load up the entity. In their scenario, the only other piece of data that they wanted to retrieve was the reference field data. And performing an entire entity_load (or node_load to be specific) would mean they would also need to load up the 50 other fields that they are storing. So doing a retrieval like this on uncached content meant that the retrieval of this data alone took 3 to 4 seconds.

Migrate more with less! Or how I learned to love and create dynamic migrations.

Thu, 02/16/2012 - 12:15 -- btmash

As many folk know (and as folk can see by my posts on the topic), I am very big fan of Migrate. It takes a while to figure out what you want to do and how to do it, but the power is absolutely immense. And having complete control over the source object down to manipulating the destination node/user/entity while still working within a framework has made this my favourite module.

Entity Caching and Drush - a sweet match.

Tue, 07/12/2011 - 10:30 -- btmash

I am a big fan of the Display Suite module. Its quite flexible and gets you up and running with a look/feel fairly quickly. One of my favourite features of Display Suite is that you can create various build modes so that they can power your views or results or have then get used in a various areas of your site. Find out how I keep things speedy through the use of the Entity Cache module with Drush.

Drupal and "Hacking" core - one possible approach

Thu, 06/30/2011 - 12:49 -- btmash
Tweet on twitter by me: Presented on hacking Drupal Core. No burning car (yet).

Over the years, I've seen and heard the phrase "Don't hack core!" mentioned by countless Drupal developers, designers, site administrators, etc. There are many blog posts on the matter (the most recent being a few weeks ago though his stance is slightly different from what I see from the rest of the community) and the number of kittens that die whenever someone hacks core. There was even a wristband created a few Drupal Conferences back. Heck, I may have had it and worn it at some point. Read on to find out.

Click here if you want to skip directly to the 'how' and slides.

Correcting views queries using views_query_alter

Thu, 06/09/2011 - 14:29 -- btmash
Letters representing tables linked to each other showing complex relationships.

I like problem solving. My good friend Oliver knows this and recently came to me with a Drupal problem that involved nodes related to other nodes and presenting them to the user in the correct order. For the Food Republic, he had galleries which contained story nodes which you could go through via a pager (showing the photo content one item at a time). Both an issue of views and *not* an issue of views, we needed to figure out a way to continue utilizing views while giving correct results.

Optimizing your site - modules gone wild.

Fri, 06/03/2011 - 23:00 -- btmash
This is a graph from munin showing how there was a large increase in queries/sec

While working on the one of the more content-heavy websites at my workplace (over 100k nodes consisting of galleries of photos, with some galleries having well over 2000 photos), I had noticed that while performance for logged in users (which isn't high since only site editors can log in) has mostly stabilized (there are areas where performance can improve), performance for all other site visitors was very inconsistent. Some of the galleries and gallery photos pages seemed to load fairly quickly while others took a few seconds for the page to show up.

Apache Solr and Ubuntu: Multiple Instances

Wed, 05/11/2011 - 16:37 -- btmash
Drupal and Solr play very well together, be it with apachesolr or search api.

At CalArts, I have wanted to move the search functionality on our Drupal powered websites into something better for a long time. We have been using the Lucene API (which is lucene search ported to PHP) module on most of them since September of last year but (even though I am a big fan of the module) we truly wanted a way to offload the search services onto another vps (or server; basically, something more flexible).

Migrating Content part 3: Nodes with your own field handlers

Wed, 04/27/2011 - 14:45 -- btmash

(Updated June 4, 2011 - address new handler requirements with Migrate 2.1 by removing stdClass)

In this finale (?) on using the Migrate module, I will go through how to go about writing your very own field handler to pull in content into a field type that does not yet have a mapped path. In this example, we will be migrating an events (so the date field from the date module will require a migration path). At the time of writing, http://drupal.org/node/1021076 had not yet been resolved (or have the ability for date_to and date_from to be established) so we will write out a field handler that handles just this!

Using the JQuery UI Date Picker for event navigation

Fri, 04/15/2011 - 12:03 -- btmash
The jQuery UI Datepicker is a fantastic way to browse through dates.

For a site I am currently creating in Drupal 7, I have a bunch of events and I need to show a view of the content in a non-traditional calendar way (Listing of events for a week, a pager to go back and forth in the week, and a calendar block which lets the user select the date (week) they want to see events occurring on).

Optimizing your site query by adding indexes

Fri, 04/08/2011 - 23:31 -- btmash
A graph of disk IO for the past 24 hours generated by munin.

I have the pleasure of working on CalArt's Photo Archive. From the conversion as a flat-file website into Drupal, the site has come a long way. And for a mid-sized website (a little over 100k nodes) running on somewhat older hardware (at least 3 years old), we are fairly happy with the performance (using the boost module allows us to serve cached content at approximately 2k requests per second). However, I was noticing that some of our content type pages were loading quite slowly prior to being cached.

Pages

Subscribe to RSS - planet drupal