SemanticMediaWiki / SummaryCards

Displays content summaries on hovered links
https://www.semantic-mediawiki.org/wiki/Extension:Summary_Cards
Other
6 stars 3 forks source link

Feature request: __NOSUMMARYCARDS__ #8

Closed krabina closed 1 year ago

krabina commented 8 years ago

It would be great to have an opportunity to omit the SummaryCard function on certain pages, e. g. with something like __NOSUMMARYCARDS__

kghbln commented 8 years ago

Yeah, such a behaviour switch could be useful on selected pages. Thanks for suggesting.

mwjames commented 8 years ago

something like __NOSUMMARYCARDS__

Using a magic word, one would need to use OutputPageParserOutput instead of the BeforePageDisplay hook.

(code is untested and requires to register __NOSUMMARYCARDS__)


$this->handlers['OutputPageParserOutput'] = function ( &$outputPage, $parserOutput ) {

    $mw = \MagicWord::get( 'NO_SUMMARYCARDS' );

    // If the text does not contain __NOSUMMARYCARDS__ then register the modules
    if ( !$mw->matchAndRemove( $parserOutput->getText() ) ) {
        $outputPage->addModuleStyles( 'ext.summary.cards.styles' );

        $outputPage->addModules(
            array(
                'ext.summary.cards'
            )
        );
    }

    return true;
};
kghbln commented 7 years ago

We would also need a "SummaryCards.magic.php" file to be able to localize __NOSUMMARYCARDS__.

kghbln commented 1 year ago

Closed per https://github.com/SemanticMediaWiki/SummaryCards/issues/17