Views Title Callback

Categories

Component ID

2693817

Component name

Views Title Callback

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

191

Component created

Component changed

Component body

Module to allow site builders specify a callback function in Views to generate the title dynamically.

Scenarios

  • Account page (Member I follow for own profile and Members followed by XXX while viewing another user's profile)
  • Displaying total number of results in title
  • Displaying value from one of the filters (normal/faceted) like Hotels in [Location]

Normally we implement hook_views_pre_render() in our custom modules to change this. But that is invoked every-time for all the views and we have to add conditions to restrict it to our desired view only.

With this module I'm trying to reduce this pain by allow developers and site builders to specify the callback function in which they can write the code to build the title. This will be stored in views definition and then will be invoked in hook_views_pre_render() implemented in only this module. I am using display_extender to get and store callback function name and then set that in $view in pre_execute() which than later is used by hook_views_pre_render().

Taken inspiration from views_access_callback and cpv modules.