DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: Body onEvents Javascript

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:Carlos Chiari
Changed:2003-07-04T09:21:34
Author:Carlos A. Chiari O.
Email:ccho@dimension-e.net
Info 3:
Info 4:

EXT: Body onEvents Javascript

Extension Key: de_addbodyjscript

Copyright 2003, Carlos A. Chiari O., <ccho@dimension-e.net>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.com

Table of Contents

EXT: Body onEvents Javascript 1

Introduction 1

What does it do? 1

Users manual 1

Configuration 2

Scope and Record Location 2

Th extension: Enabling it, Disabling it, and supporting Multiple Sites 2

Sorting 3

Global record on a page item without properly set Template 3

HTML Templates 3

Known problems 3

Change Log 3

Version 0.1.3 3

Introduction

What does it do?

Most probably you will not need this extension.

Anyway, this script is intended to make easy the inserting of javascript codes into these event handlers:

  • onload
  • onmouseup
  • onmousemove

For example, If your designer made an HTML template with a “preloadImages” function for its rollover efect; and after that you inserted the “includeLibs.myMenu = media/scripts/gmenu_foldout.php” code into your typo3 template, you will end with two “onLoad” calls in your final HTML code:

<body onLoad="MM_preloadImages('fileadmin/images/myimages.gif',' fileadmin/images/myimages2.gif');" bgcolor=#ffffff onload="T3_onloadWrapper();">

As you can see, there are two onLoad commands... and the gmenu_foldout will not work.

Users manual

This extension is intended for administrators or developers.

The extension has three types of elements you can insert into your pages, one for each type of event handler that typo3 can insert into the BODY tag via the $GLOBALS['TSFE']->JSeventFuncCalls array:

  • onload
  • onmouseup
  • onmousemove

When you insert a “Body onEvents Javascript” record to your page, you have these fields:

Hide: Default on typo3.

Global Scope: If this javascript call should work on a global scope, that is, in all the site, check this. Otherwise, leave it blank.

Global Sorting: Has to be an Integer, up to 4 digits. The value in this field is used to sort the global records, in order. (i.e.: 1, 2, 3 ...)

Title: For your own use, to recognize your records.

Event Type: Type of event handler.

Javascript Call: This is the code that will be appended to the event handler at the BODY tag. Important: You have to comply the javascript syntax, and add a “;” semicolon at the end of each line.

((generated))

Example

At any page, insert this item:

img-1

Click at your page and look!

Configuration

Scope and Record Location

The place where you put your Record, if the javascript call has a local scope, is important. For local javascript calls, it will be used only on the specific page it is located.

On the other hand, you can put global scope javascript calls anywhere in your tree.

Th extension: Enabling it, Disabling it, and supporting Multiple Sites

Enabling the extension

The extension uses this code by default to enable itself:

page.1013 < plugin.tx_deaddbodyjscript_pi1

If you have a PAGE content with another name, eg. “mypageobject”, or want to have this in another cObject, eg. “2000”, you should change this at your typoscript:

mypageobject.2000 < plugin.tx_deaddbodyjscript_pi1

Disabling the extension

At your typoscript, you have to clear the page cObject where you have inserted the plugin:

page.1013 >

Multiple Site Support

The script will only process plugin records, at each page, that have the same root line the page has. This means that even the records with a GLOBAL scope will only be processed if they are part of the same Tree, and thus, you can have the extension on an installation with multiple sites.

Sorting

The extension will parse -add to the javascript code- the records in this order:

Global Scope, by “Global Sorting” field, ascending (1, 2, 3 ...)

Local Scope, by “sorting”, i.e: in the order they appear at the page's records list, from top to bottom.

To modify the order in a Global record, change the “Global Sorting” field value.

To modify the order in a Local record, change its position on the page.

Global record on a page item without properly set Template

You should put global records on a branch of your tree that has a properly set PAGE object in its templates.

Otherwise, you will get the standard “TYPO3 Error” Message:

img-2

This happens because the script uses this method, $GLOBALS['TSFE']->getPageAndRootline() , to get items rootLine.

If this happens to you, just move the record to a page you know is working without this message.

HTML Templates

You will have to make yourself sure that your HTML templates comply with the requirement of having no javascript call.

Instead, cut them from your original HTML template, and paste them into a “Body onEvents Javascript” record of the corresponding type.

Known problems

Global records should not be placed on an not properly set page. Please refer to the configuration section.

Change Log

Version 0.1.2

Modified:

Sorting Mechanism .

  1. Global scope records are inserted first, then local scope records.
  2. Global records sorted by “Global Sorting” field.

img-3 EXT: Body onEvents Javascript - 3