Add buttons in views

When I create a new view, the import activities and add activity button does not appear. How can I get the buttons like in the picture?

1 Like

Good question!

These are added as Local Tasks in Drupal 7: hook_menu_local_tasks_alter | system.api.php | Drupal 7.x | Drupal API

You could add them to your view by implementing hook_menu_local_tasks_alter yourself, or by implementing hook_farm_ui_actions as documented here: farmOS/farm_ui.api.php at 7.x-1.x Ā· farmOS/farmOS Ā· GitHub

Many of the actions links you see are provided by the farm_ui module right here: farmOS/farm_ui.farm_ui.inc at 7.x-1.x Ā· farmOS/farmOS Ā· GitHub

Import links provided by farm_import module: farmOS/farm_import.module at 7.x-1.x Ā· farmOS/farmOS Ā· GitHub

Note that this will be different in farmOS 2.x!

1 Like

To add to @paul121’s answer…

farmOS provides a custom hook_farm_ui_entities(), which your module can implement to describe to farmOS what entity types it provides (asset types, log types, plan types, and taxonomy term types).

The ā€œImport activityā€ and ā€œAdd activityā€ links are auto-generated by the farm_ui module on behalf of any module that implements hook_farm_ui_entities(). So if you implement just that hook in your module it will take care of this (and many other things) for you automatically.

Here is what the Activity module’s implementation of that hook looks like, for reference: farmOS/farm_log_activity.module at 7.x-1.x Ā· farmOS/farmOS Ā· GitHub

(Note that in farmOS 2.x, hook_farm_ui_entities() is no longer necessary and these action links are automatically added for all log types.)