Drupal 7: Extend Views Plugin Style

Portland ME - I needed to change the way the Jump Menu style plugin worked in Views on a recent project. The client wanted certain items in the jump menu to link to external websites. To accomplish this, I added a field to my content type that would store the external URL and then I had to extend the Views Plugin Style for the Jump Menu.

In order to extend the plugin style you will need a custom module. We will refer to the module as 'my_module'. Here are the files that will make up the module and there purpose.

my_module.info


name = My Module
description = Extend the Views Jump Menu Style Plugin
core = 7.x
files[] = my_module_views_plugin_style_jump_menu.inc

Notice the line that starts with files[]. This will tell Drupal to load this file because it contains our extended class definition.

my_module.module


We use hook_views_plugins_alter() to override the current handler to our own custom handler.

my_module_views_plugin_style_jump_menu.inc


You can name this file anything you want just like you can name the class anything you want. You just need to make sure the file name is the same as what is set in the .info file and the class name matches what is set in the hook_views_plugins_alter function. When extending another existing class, you can take the function from the class and modify it in your extending class. You do not need to copy over the other functions, they will still function the same as what is set in original class. Jordan Release Dates 2016



Comments (0)

About Us

We are web developers versed in front and back end technologies. We like PHP, Drupal and Wordpress for our web apps and Foundation, Bootstrap, SUSY and Sass for our User Interfaces. Contact us to be apart of your next web project.

Latest Articles

Copyright © 2019 Focal55 Inc. / All rights reserved.