'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( "/| '.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.' ).' |