---+!! !SortedHeadPlugin
<a href="http://wikiring.com"><img src="%ATTACHURL%/hat.png" style="float:right" /></a>
<!--
One line description, required for extensions repository catalog.
   * Set SHORTDESCRIPTION = Support for sorting of HEAD tags
-->
%SHORTDESCRIPTION%

%TOC%

This plugin implements sorting of tags within the HEAD block of a generated
HTML page. The plugin monkey-patches TWiki to modify existing code. As such
it will *not* work with all TWiki versions.

Currently plugins call TWiki::Func::addToHEAD to add javascript and css text and file includes to the html &lt;head&gt; tag. The TWiki core blindly adds these to the header.

This plugin is a demonstrator for a technique that will probably be
incorporated into the core.

---++ Usage
---+++ =%<nop>ADDTOHEAD%=
You can write =%ADDTOHEAD{...}%= in a topic or template. This variable accepts the following parameters:
   * =_DEFAULT= optional, id of the head block. Used to generate a comment in the output HTML.
   * =text= optional, text to use for the head block. Mutually exclusive with =topic=.
   * =topic= optional, full TWiki path name of a topic that contains the full text to use for the head block. Mutually exclusive with =text=.
   * =requires= optional, comma-separated list of id's of other head blocks this one depends on.
=%<nop>ADDTOHEAD%= expands in-place to the empty string, unless there is an error in which case the variable expands to an error string.

---+++ TWiki::Func::AddToHEAD
=TWiki::Func::addToHEAD= is modified to accept two new parameters, =$text= and =$requires=, which have the same behaviours as the equivaent =%<nop>ADDTOHEAD%= parameters.

---+++ %<nop}RENDERHEAD%
=%RENDERHEAD%= should be written where you want the sorted head tags to be generated. This will normally be in a template. The variable expands to a sorted list of the head blocks added up to the point the RENDERHEAD variable is expanded. Each expanded head block is preceded by an HTML comment that records the ID of the head block.

Head blocks are sorted to satisfy all their =requires= constraints.
The output order of blocks with no =requires= value is undefined. If cycles
exist in the dependency order, the cycles will be broken but the resulting
order of blocks in the cycle is undefined.

---++ Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully
automatic installer script written using the Build<nop>Contrib.
   * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
      * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
   * If you have any problems, then you can still install manually from the command-line:
      1 Download one of the =.zip= or =.tgz= archives
      1 Unpack the archive in the root directory of your TWiki installation.
      1 Run the installer script ( =perl &lt;module&gt;_installer= )
      1 Run =configure= and enable the module, if it is a plugin.
      1 Repeat for any missing dependencies.
   * If you are *still* having problems, then instead of running the installer script:
      1 Make sure that the file permissions allow the webserver user to access all files.
      1 Check in any installed files that have existing =,v= files in your existing install (take care *not* to lock the files when you check in)
      1 Manually edit !LocalSite.cfg to set any configuration variables.

%IF{"defined 'SYSTEMWEB'" else="<div class='twikiAlert'>%X% WARNING: SYSTEMWEB is not defined in this TWiki. Please add these definitions to your %MAINWEB%.TWikiPreferences, if they are not already there:<br><pre>   * <nop>Set SYSTEMWEB = %<nop>TWIKIWEB%<br>   * <nop>Set USERSWEB = %<nop>MAINWEB%</pre></div>"}%


---++ Plugin Info

Another great TWiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!

Many thanks to the following sponsors for supporting this work:
   * C-Dot Consultants http://c-dot.co.uk

|  Plugin Author(s): | Crawford Currie http://c-dot.co.uk |
|  Copyright: | &copy; Crawford Currie http://c-dot.co.uk |
|  License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
|  Plugin Version: | 0 (29 Apr 2008) |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
|  Dependencies: | None |
|  Plugin Home: | http://twiki.org/cgi-bin/view/Plugins/SortedHeadPlugin |
|  Feedback: | http://twiki.org/cgi-bin/view/Plugins/SortedHeadPluginDev |
|  Appraisal: | http://twiki.org/cgi-bin/view/Plugins/SortedHeadPluginAppraisal |

__Related Topics:__ %TWIKIWEB%.TWikiPlugins, %TWIKIWEB%.DeveloperDocumentationCategory, %TWIKIWEB%.AdminDocumentationCategory, %TWIKIWEB%.TWikiPreferences

<!-- Do _not_ attempt to edit this topic; it is auto-generated. Please add comments/questions/remarks to the feedback topic on twiki.org instead. -->
