Difference between revisions of "Hooks"

From Tweeki
Jump to: navigation, search
(SkinTweekiAdditionalBodyClasses)
 
Line 19: Line 19:
  
 
  $wgHooks['SkinTweekiAdditionalBodyClasses'][] = 'MyExtensionHooks::onSkinTweekiAdditionalBodyClasses';
 
  $wgHooks['SkinTweekiAdditionalBodyClasses'][] = 'MyExtensionHooks::onSkinTweekiAdditionalBodyClasses';
 +
 +
=== SkinTweekiCheckVisibility ===
 +
 +
Use this hook to dynamically hide navigational elements and sections. Returning <code>false</code> means the item should not be shown. The following example hides the footer for users without confirmed email address.
 +
 +
public static function onSkinTweekiCheckVisibility( $skinTweeki, $item ) {
 +
  if( $item == 'footer' && !$skinTweeki->getSkin()->getUser()->isEmailConfirmed() )
 +
    return false;
 +
  }
 +
}
 +
 +
$wgHooks['SkinTweekiCheckVisibility'][] = 'MyExtensionHooks::onSkinTweekiCheckVisibility';

Latest revision as of 22:16, 10 March 2017

SkinTweekiStyleModules

works similar to SkinVectorStyleModules

public static function onSkinTweekiStyleModules( $skinTweeki, &$styles ) { ... }
$wgHooks['SkinTweekiStyleModules'][] = 'MyExtensionHooks::onSkinTweekiStyleModules';

SkinTweekiAdditionalBodyClasses

Use this hook in order to add dynamic custom classes to the <body> tag.

public static function onSkinTweekiAdditionalBodyClasses( $skinTweeki, &$additionalBodyClasses ) { 
  $newClass = 'rand' . rand(0,1);
  $additionalBodyClasses[] = $newClass;
  return true;
}
$wgHooks['SkinTweekiAdditionalBodyClasses'][] = 'MyExtensionHooks::onSkinTweekiAdditionalBodyClasses';

SkinTweekiCheckVisibility

Use this hook to dynamically hide navigational elements and sections. Returning false means the item should not be shown. The following example hides the footer for users without confirmed email address.

public static function onSkinTweekiCheckVisibility( $skinTweeki, $item ) { 
  if( $item == 'footer' && !$skinTweeki->getSkin()->getUser()->isEmailConfirmed() )
    return false;
  }
}
$wgHooks['SkinTweekiCheckVisibility'][] = 'MyExtensionHooks::onSkinTweekiCheckVisibility';