module development

Articles about module development

Drupal 8 and hook form alter: How to check if taxonomy term is new or old?

Oct
2020
08
If you want to check with hook_form_alter if the taxonomy term is new or updated (old) you can't use the form_id or the $form_state->getFormObject()->getOperation() because it always returns "default". The solution for this is : $form_state->getFormObject()->getEntity()->isNew() So for example:

How to disable a block programmaticaly with drupal 8

Aug
2020
11
On my custom theme i have a region with 2 blocks. It is an event region block. The first block is a header block and the second block is a view block that renders the active - running events. However when there are no events the view result is an empty result so nothing is rendered but the header events block remains there.

Altering image field widget “alt” or title" label

Jan
2017
04
For altering the "Title" and "Alternate Text" textfields of an image field we have to add an extra Proccess function for the widget form.
// Alter image Title for field_top_image instance
function MYMODULE_field_widget_form_alter(&$element, &$form_state, $context) {

Controlling block page display options programatically

Apr
2015
06
You can set the region, the weight and the path of custom block in a custom module like this:
function hook_block_info(){
    $blocks = array();
    $blocks['my_custom_block'] = array(
        'info' => t('Custom Block Options'),
        'status' => TRUE,

Views and Taxonomy Terms Translation

Feb
2013
12
Have you ever searched “Views” for a way to filter the taxonomy terms by language (as done for nodes), but you didn't find a way to do it? Does “Views” also support that filter in taxonomies or only in nodes? How can I filter the taxonomy terms by language?

Pages

Subscribe to RSS - module development
this is an arrow pointing back to the top of the page