Monday, 1 July 2013

When and why to choose to use a Drupal custom entity


Entities introduced into Drupal 7 and a number of contrib modules significantly improved the data modelling capabilities of Drupal. Prior to entities we were stuck with add-hoc solutions and data modelling that was essentially based on making modifications to data structures designed for page related content.

It is still not trivial to get started with entities however, especially difficult to get past the ingrained response to solving every data modelling problem by creating a new content type and adding fields.

Drupal as a framework (the role of entities)


This is my second post in a series of related posts about Drupal entities the first is here.

If Drupal was predominately a framework as opposed to a customisable CMS then you would expect that a skilled PHP programmer with a good understanding of appropriate design patterns from other frameworks (MVC etc.) could reasonably quickly start from scratch with Drupal to build a moderately complex and well designed website.

Unfortunately this is not the case at the moment, the learning curve for Drupal is still too steep for most people to pull this off. One aspect of the "Drupal way" is to not re-invent the the wheel and to use from the massive selection of community contributed modules to implement your required functionality, and this works well for relatively simple sites.

Of course you could point out that Drupal is essentially a CMS, but it is increasingly being used for functionality that goes far beyond a traditional CMS and in those cases it is fair to ask how does it stack up as a framework. Sometimes software like Drupal will also be described as a content management framework (CMF), it may put things in perspective to see a list of software that could be considered in a similar space.

Where Entities step in to raise the bar for Drupal is in the role of modelling data.

Sometimes you have to write code, maybe your requirements are not mainstream enough to have a custom module or you have to integrate with a bespoke API or your clients are using Newsweaver rather than MailChimp or you have to integrate a bunch of contrib. modules in a way that was never envisaged. Of course all those wonderful custom modules required development and Drupal core requires a continual injection of developers that can work on the next generation of Drupal required for the ever involving web.

Not surprisingly the higher paid developer roles expect you to write quite a lot of code...

Sunday, 30 June 2013

Background to Drupal entities


The first of a series of related posts about Drupal custom entities, all will be linked into here as they are published. If not useful in themselves I hope to at least provide lots of links to useful entity resources online.

Entities were introduced into Drupal 7, they fundamentally change the way you can deal with things in Drupal and pave the way for some vast improvements in the use of Drupal as a development framework (rather than a CMS with customizable bits and modules that can be bolted on).

Entities are not proving easy for people to get into, although embraced by a number of contributed modules, many working Drupal developers don't fully understand or use them and although there are plenty of resources and explanations about them it is not easy to get started using them.

I believe that a key factor in the small number of developers embracing entities is that they are not directly exposed to site builders in Drupal 7, there is no sliding scale of entity use in core, you have to know about how they work and get your hands dirty.

Mastery of Entities may have been 'Take it or leave it' for a lot of developers building Drupal sites in Drupal 7 but I think for Drupal 8 they will be vital knowledge for anybody building medium to large Drupal sites.

Thursday, 27 June 2013

Shoddy Drupal security advice from

Getting back into twitter and quickly encountering some of the things I dislike about the current social media and information saturation: shoddy content pushed out merely for traffic purposes and that thinly disguised advertising.
This article 10 Simple steps to protect your Drupal site is bad, bad, BAD. Apart from the fact that there is no distinction between upgrade and update (are you really going to do all that just to update a module?) there is some lame advice about file permissions (755 is more secure than 644 really???).

Friday, 7 June 2013

New WordPress blog on the way

I started blogging about language learning many years ago (about seven I think), at the time using a service like Blogger was the path of least resistance, I was working on publishing platforms for online Journals and magazines and didn't at work, at home I wanted to learn languages not more of the same.

Now I feel a need to have an online presence that represents me centrally on the web and I want to control that rather than being enslaved to an online service. I have had (although my name is Christopher David Hall I always associate the full 'Christopher' as being in trouble as that is the only time anyone calls me that) for some time now but put nothing there.

Sunday, 29 July 2012

WordPress learning from the code in

My knowledge of WordPress is increasing quickly with little bits of time here and there, and I think I have finally found some functionality that will require me to develop a proper plugin, there doesn't seem to be a plugin that gives the same functionality of node references in Drupal (although that appears to be giving way to more generic entity references). Basically I want to add another post type and make a reference to it from normal posts. I have to trawl through the plugins some more but so far nothing does exactly what I want.

Monday, 16 July 2012

WordPress from the ground up


I have been putting some time aside to learning WordPress recently, in the the past I have had to do little bits and pieces on WordPress sites or a fiddle with something that doesn't quite work on a site built by someone else on top of a specialized theme that has been purchased. I wanted to learn how WordPress works from the bottom up.
I also want to get a feel for how much customization is possible and the feasibility of using WordPress as a development framework. I have a personal project in mind that theoretically I could build in Drupal, however Drupal is a bit weighty for what I want and a WordPress based project should be much easier for people to set up and install.

Thursday, 12 July 2012

Themeing Drupal 7: Depends on the team

Another steep learning Curve.

A quick comment, following some discussion with other Drupal developers and interested parties last week at the last Bristol & The West, UK Drupal group meetup. It quickly became clear that my search for simplicity in themeing Drupal is ultimately doomed. I know too many ways to do things, there are too many valid approaches.

The consensus appears to be that the skill-set and availability of members in the team will make a huge difference. Having a front-end developer that does not know Drupal inevitably moves a lot of the load back to the back-end developer (or at least introduces a heavy training/knowledge sharing penalty).

Although I can imagine a happier world where the developer is mostly concerned with making sure that the data is there and managing the display tab and view modes in content types, there are lots of times where this is simply not practical.

I shouldn't need a helper module to give me clues about where various bits of the page are being themed. I may have to trace theme functions in the code or trawl through a disparate set of template files that individually give no clue to their heirachy or conceptual inheritance.

Quite a few people seem to be looking forward to Twig in Drupal 8 another post on that soon I think.

Wednesday, 4 July 2012

Themeing Drupal 7: Checking fields


A very general thought, will add more specifics when I have done a bit more investigation.
Considering the template end of themeing (so ignoring theme functions for this thought experiment) and restricting to a node template or field templates. Assuming you have have a set of various different fields (some with multiple values perhaps) and you wish to customise the display of the content somewhat perhaps wrapping some of the fields in html to make a carousel or for something else. Is there ever a case where you need write complex PHP in the template/s?

Tuesday, 3 July 2012

Drupal as framework pt2 where is my front controller?


Continuing thoughts on Drupal7 (and to be fair probably just an exercise in tidying up my brain and not much use to others) as a web development framework, I highlighted one of the major difficulties in part 1 in that you need to know a lot about Drupal before you can use it as a framework.
This post is a quick pointer if you come from a pure framework background and are trying to understand how Drupal 7 works.

Sunday, 24 June 2012

Drupal bean module


The Drupal Bean module makes blocks into fieldable entities, providing some useful UI features for blocks out of the box and allows developers to create new block types in code via ctools plugins. From the documentation:

"Each bean instance has a corresponding block. Users interact with them in the same way they might use any other block in Drupal. The Bean module does not attempt to interface with the placement of blocks. Bean deals only with the creation of customized, fieldable blocks."

I haven't tried Beans yet but can see how useful they could be, particularly in some places where views are overloaded. Filling bean content via EntityFieldQueries is a viable approach (and probably often better) to many problems that are solved with view blocks.

Further Reading

An interesting looking implementation of beans is the relevant content bean. This is feature in the following bean module tutorial:

The article Views without views discusses beans and this module also.