Exporting taxonomy terms in Drupal 7

Firstly you’ll need to install the UUID Features (https://drupal.org/project/uuid_features) , Features (https://drupal.org/project/features) and UUID (https://drupal.org/project/uuid) modules.

Once all those modules are enabled, go to example.com/admin/config/content/uuid_features (or on your administration menu go to Administration –> Content Authoring –> UUID Features Integration, and under “Exportable Taxonomy term bundles” check the boxes for the relevant taxonomy terms.

Go to your features export page at example.com/admin/structure/features/ (or on your administration menu go to Administration –> Structure –> Features), create/recreate the feature and you’ll see “Taxonomy Terms” listed.

Happy exporting!!

Advertisements

A HTML template for Drupal module reviews

…. Because I am so painfully lazy, here is a template for reviewing Drupal modules following the guidance at https://drupal.org/node/1587704.

<strong>Issues Summary</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Basic application checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Repository checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Security review</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Licensing checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Documentation checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Coding standards</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>API and best practices review</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

Accessing Drupal sandbox projects via the web

EDIT: OK so there’s an even easier way to do this…  Click on “Repository viewer” on the right hand menu under the “Development” heading

Screenshot 2013-12-24 14.52.26

OK, so for some reason when I want to view Drupal modules I can’t access them via the usual “git clone (git_url_here)” command.

So instead the source code can be accessed by going to drupalcode.org … but how? Good question :D!

As an example, let’s say you want to check out my sandbox project https://drupal.org/sandbox/ajosephau/2105389 ?

Go to http://drupalcode.org/sandbox/ajosephau/2105389.git

So the format is http://drupalcode.org/sandbox/”USERNAME”/”GIT_REPO_ID”.git from the URL.

To download a particular version, click on the URL “snapshot” for a particular revision.

comment_comment_docblock_missing Drupal 7 Coder module

Ever get a minor warning for “comment_comment_docblock_missing” when using Drupal 7 Coder module? Even when you have included a docblock?!?

I found it was my file encoding – I had it set to Windows instead of Linux files :-(. Serves me right for developing on an XP machine!

A simple way to create arrays for Drupal testing

So after not playing Company of Heroes…. I’m back on Drupal module development, in particular how to create tests as quickly as possible.

I found two things:

    You can print out php arrays, classes etc pretty easily by using the “var_export($array,TRUE)” function (thanks Stack overflow! stackoverflow.com/questions/6759864/how-to-create-an-array-from-var-dump-result )
    And when you get things like “stdClass::__set_state()” you can replace it with a cast to object, like “(object)”. Thanks Drupal forums… https://drupal.org/node/584672

Now there’s no excuse for not testing your code :-)!

Adding a configure link to a Drupal module

If you want to add a “Configure” link to a module’s entry in the ‘Administration >> Modules’ page, add the following line to a module’s “.info” file:

configure = path/to/admin/page

This path’ll be in your hook_menu() implementation.

Thanks to this bug report I found https://drupal.org/node/1582464

Inserting tags in HEAD section of a Drupal page

The “hook_html_head_alter()” can let you add tags to the HEAD section of a Drupal page. Despite some of the comments, I found that if you need to put it into a module in Drupal 7, you do need to name the hook after the module’s name, instead of just “template_”….

If you want to build tags… the Drupal way :-P… try the function theme_html_tag().

I found this was useful for a module I was writing… stay tuned people :-).