Feature Proposal: Standard Mechanism to Add Content to the HEAD Section
Motivation
Some plugins (like
EditTablePlugin and
XpTrackerPlugin) need to add some javavascript and/or custom css to topics.
Currently, there are only two ways to do that:
- Embeed the script/css into the topic text (non-standard, but work)
- use the hack found in EditTablePlugin:
if( ( $_[0] =~ m/^[<][!]DOCTYPE/ ) {
$_[0] =~ s/([<]\/head[>])/$text-to-add$1/i;
}
Description
Provide a method in
FuncDotPm that allows Plugins to register chunks of text to be included in the HEAD section.
From the PODs in the patch:
---+++ addToHTMLHead($tag,$header)
Adds =$header= to the HTML header (the <head> tags)
This is useful for plugins that want to include some javascript library or a custom css.
* =$tag= - Unique ID to prevent duplicated. It's suggested that Plugins use a suffix to prevent name clashed (ie: EDITTABLEPLUGIN_JSCALENDAR)
* =$header= - the text to be added to the <head> section
All tags pressent in =$header= will be expanded before being inserted into the =<head>= section.
*Since:* TWiki::Plugins::VERSION 1.026
example:
TWiki::Func::addToHTMLHead('PATTERN_STYLE','<link id="twikiLayoutCss" rel="stylesheet" type="text/css" href="http://acsele29:5050/develop/DEVELOP/pub/TWiki/PatternSkin/layout.css" media="all" />')
EditTablePlugin was modified to use this enhancement instead of it's old hack.
--
RafaelAlvarez - 18 Jul 2005
Impact and Available Solutions
Note: Patch is attached as
https://www.twiki.org/p/pub/Codev/MechanismToAddContentToHEAD/headerhook4662.diff. The patch is against DEVELOPBranch r4662.
Discussion:
Being able to add into the heading section of the generated page in a systematic way is an urgent need. Thanks.
--
ThomasWeigert - 18 Jul 2005
OK, I agree, also needed for
ActionTrackerPlugin. Added
Bugs:Item128
, replacing this topic.
--
CrawfordCurrie - 21 Jul 2005
hmm,
CrawfordCurrie beat me to it. Up in
SVN 4680
--
RafaelAlvarez - 21 Jul 2005
Heh; I applied your patch, so I cheated
--
CrawfordCurrie - 21 Jul 2005
This is already in the core, sin
DakarRelease
--
RafaelAlvarez - 08 Aug 2008