Jump to content

Extension:IntegratedProfiles/Hooks/IntegratedProfilesRenderTab

From mediawiki.org
IntegratedProfilesRenderTab
Available from version 0.1.0
Fills HTML for a tab when it is the active tab (requires onIntegratedProfilesGetTabs to be called first).
Define function:
public static function onIntegratedProfilesRenderTab( string $tab_id, string &$html, array $profile, IContextSource $context ) { ... }
Attach hook:
$wgHooks['IntegratedProfilesRenderTab'][] = 'MyExtensionHooks::onIntegratedProfilesRenderTab';
Called from:
File(s): IntegratedProfiles / src/ProfilePage.php
Function(s): view

For more information about attaching hooks, see Manual:Hooks .
For examples of other extensions using this hook, see Category:IntegratedProfilesRenderTab extensions.

Fills HTML for a tab when it is active (requires onIntegratedProfilesGetTabs to be called first). Intended for extensions, but can work elsewhere.

Details

[edit]
  • $tab_id: A string matching an ID registered via IntegratedProfilesGetTabs. Cannot be 'about' or 'contributions'
  • &$html: Mutable panel HTML.
  • $profile
  • $context

Usage

[edit]
/**
  * Render a custom tab panel with IntegratedProfiles that has been registered via IntegratedProfilesGetTabs.
  *
  * @param array<string,mixed> $profile
  */
public function onIntegratedProfilesRenderTab( string $tab_id, string &$html, array $profile, IContextSource $context ): void {
  if ( $tab_id !== 'customtab1' ) {
    return;
  }

  $user_id = (int)( $profile['user_id'] ?? 0 );
  if ( $user_id <= 0 ) {
    return;
  }

  $context->getOutput()->addModuleStyles('ext.MyExtension.styles');
  $html = /* ... */;
}

See also

[edit]