How to show hierarchy in Drupal’s Solr Search Api Facets?

Standaard
  • Go to admin/config/search/search_api/index/*your solr server*/workflow.
  • Check the box ‘Index Hierarchy’.
  • Select the taxonomy fields where you would like to apply the hierarchy.

Is Drupal’s l() function causing ‘operator not support for strings common.inc’?

Standaard

Previously I was confronted with an error while simply using the Drupal l() function. In this l() function I was trying to give the HTML a-tag a specific class attribute value. The following code was in my module:

l(‘some url text’, ‘the-path-for-the-current-active-page’, array(‘attributes’ => array(‘class’ => ‘custom-class’)))

When calling the page containing the link from above, I received the ‘operator not supported for strings’ error. It seemed that the l() function that at default tried to set the class attribute ‘active’, was causing the error. By removing the parameter for setting the class attribute, the problem got solved. My link now looks like:

l(‘some url text’, ‘the-path-for-the-current-active-page’)

This doesn’t cause any errors anymore.

Why is the mtime added in my Drupal module’s .info file?

Standaard

Since the Drupal Core update of version 7.34 all modules being updated contain an mtime text rule in the .info file.

This is caused by the Drupal core system.module file.

// Add the info file modification time, so it becomes available for
// contributed modules to use for ordering module lists.
$module->info[‘mtime’] = filemtime(dirname($module->uri) . ‘/’ . $module->name . ‘.info’);

How to create an anchor link per node in Drupal views

Standaard

Creating anchor links in views in Drupal can be very easy. You can to it this way:

  • In the view render the output as fields.
  • Add the field ‘Content: path’.
  • Open the fieldset ‘Rewrite results’.
  • Check the rewrite output checkbox.
  • Enter the following text in the rewrite output textarea:
    • <a href='[path]#youranchor’>Your custom link text</a>

The [path] token is the path alias of the node and can be found in the replace patterns section.

How to get the full taxonomy term level path in the url with autopath in Drupal 7.

Standaard

If you want to show all levels of the taxonomy term in the path, you can simply enter the following to your taxonomy url pattern in admin/config/search/path/patterns

[term:parents:join:/]/[term:name]

How to solve the drush message ‘Directory …drush/cache/default exists, but is not writable. Please check directory permissions.’?

Standaard

In the OSX execute the following command:

chown -R $USER ~/.drush

In case you receive the following message:
chown: ….drush/cache/default: Operation not permitted

Then execute the command again, but with sudo:

sudo chown -R $USER ~/.drush

More info can be found on https://drupal.org/node/1488682

How to delete a content type field programmaticaly in Drupal

Standaard

Delete a field within a content type
// Get the field instance object for a particular content type
$field = field_info_instance('node', 'your-field-name', 'content-type-machine-name');
// And delete it
field_delete_instance($field);

Delete all instances of a field
// Get the field instance object
$field = field_info_field(‘your-field-name’);
// And delete all instances of this field
field_delete_field($field);