'Back to Top', 'description' => 'Add back to top link to headers.
We recommend that you add something like this to your CSS file:
a.backtotop {display:block;text-align:right;}', 'auto_activate' => false, 'plugin_type' => FILTER_PLUGIN, // filter functions 'postparse_function' => '\Bitweaver\Liberty\backtotop_postparsefilter', // these settings are to get the plugin help working on content edit pages 'tag' => 'backtotop', 'help_page' => 'FilterPluginBacktoTop', 'help_function' => 'backtotop_help', 'syntax' => '{backtotop}', ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_FILTERBACKTOTOP, $pluginParams ); function backtotop_postparsefilter( &$pData, &$pFilterHash ) { global $gBitSmarty; if( preg_match( "/\{(backtotop[^\}]*)\}/i", $pData, $backtotop )) { // remove {backtotop} from page $pData = preg_replace( '#(

)?'.preg_quote( $backtotop[0], '#' ).'(

)?(\s*<[Bb][Rr]\s*/?>)?#', '', $pData ); // default values $params['min'] = 1; $params['max'] = 6; $params = array_merge( $params, KernelTools::parse_xml_attributes( $backtotop[1] )); $biticon = [ 'ipackage' => 'icons', 'iname' => 'go-top', 'iexplain' => 'Back to top', ]; // get all headers into an array preg_match_all( "/]*)>.*?<\/h\d>/i", $pData, $headers ); $link = ''.\Bitweaver\Liberty\smarty_function_biticon( $biticon, $gBitSmarty ).''; foreach( $headers[0] as $key => $header ) { if( $headers[1][$key] >= $params['min'] && $headers[1][$key] <= $params['max'] ) { $pData = str_replace( $header, $link.$header, $pData ); } } $pData .= $link; } } function backtotop_help() { return '
'.KernelTools::tra( "Key" ).' '.KernelTools::tra( "Type" ).' '.KernelTools::tra( "Comments" ).'
min '.KernelTools::tra( "numeric").'
('.KernelTools::tra("optional").')
'.KernelTools::tra( 'If you specify 2 here, backtotop will only add links from h2 to h6 level.' ).'
max '.KernelTools::tra( "numeric").'
('.KernelTools::tra("optional").')
'.KernelTools::tra( 'If you specify 3 here, backtotop will only add links from h1 to h3 level.' ).'
'. KernelTools::tra("Example: ").'{backtotop min=2 max=3}'; }