Difference between revisions of "Hooks"
From Tweeki
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
=== SkinTweekiAdditionalBodyClasses === | === SkinTweekiAdditionalBodyClasses === | ||
− | add classes to the <code><body></code> tag | + | Use this hook in order to add dynamic custom classes to the <code><body></code> tag. |
− | public static function onSkinTweekiAdditionalBodyClasses( $skinTweeki, &$ | + | public static function onSkinTweekiAdditionalBodyClasses( $skinTweeki, &$additionalBodyClasses ) { |
+ | $newClass = 'rand' . rand(0,1); | ||
+ | $additionalBodyClasses[] = $newClass; | ||
+ | return true; | ||
+ | } | ||
$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 21: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';