archive_me1Add my vote for this tag create new tag
, view all tags

Feature Proposal: Standard Mechanism to Add Content to the HEAD Section


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:

  1. Embeed the script/css into the topic text (non-standard, but work)
  2. use the hack found in EditTablePlugin:
if( ( $_[0] =~ m/^[<][!]DOCTYPE/ ) {
$_[0] =~ s/([<]\/head[>])/$text-to-add$1/i;


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 

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 http://www.twiki.org/p/pub/Codev/MechanismToAddContentToHEAD/headerhook4662.diff. The patch is against DEVELOPBranch r4662.


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 hehe!

-- CrawfordCurrie - 21 Jul 2005

This is already in the core, sin DakarRelease

-- RafaelAlvarez - 08 Aug 2008

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff headerhook4662.diff r1 manage 5.1 K 2005-07-18 - 00:32 RafaelAlvarez Diff against 4662
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2008-08-08 - RafaelAlvarez
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.