Bug #2261

Standard inclusion of JS makes other JS Libraries unuable

Added by Lukas Taferner 211 days ago. Updated 172 days ago.

Status:Resolved Start:2008-12-03
Priority:Should have Due date:
Assigned to:Alex Kellner % Done:

0%

Category:Frontend Spent time: -
Target version:-

Description

Hi Alex,

after upgrading to Powermail 1.4 I discorvered that the following JS files are included by default in all pages:
<script src="typo3conf/ext/powermail/js/checkbox/checkbox.js" type="text/javascript"></script>
<script src="typo3conf/ext/powermail/js/mandatoryjs/lib/prototype.js" type="text/javascript"></script>
<script src="typo3conf/ext/powermail/js/mandatoryjs/src/effects.js" type="text/javascript"></script>
<script src="typo3conf/ext/powermail/js/mandatoryjs/fabtabulous.js" type="text/javascript"></script>

The problem is that prototype blocks i.e. mootols and produces JS errors. The TS Setup does not look like there is a switch provided like in older versions of Powermail. It would be great to have one constant (or EM config) to generally disable JS inclusion or include the static template only on those pages that have powermail forms (via pi1) if not disabled by TS / Const.

Best regards,

Lukas

History

2008-12-03 15:49 - Alex Kellner

  • Category set to Frontend
  • Status changed from New to Needs Feedback
  • Assigned to set to Alex Kellner
  • Priority changed from Must have to Could have

I've heard about the problem, but I don't use mootools so this is not a problem for me or for many other powermail users.
I think js integration via typoscript is much more better than the old way (javascript files were included via php), so I want to use this method in the future.

My proposal: We remove the typoscript lines for automatic js file integration from the ext_typoscript_setup.txt and move them to a static template.
Disadvantage of this offer: JS wont be included automaticly and the admin has to add an extension template on the powermail page and add the static template.

I think there is no perfect way with this issue!

2008-12-06 22:58 - Alex Kellner

  • Status changed from Needs Feedback to Accepted
  • Priority changed from Could have to Should have

I think I found a solution for this problem

What I want:
- JS inclusion via typoscript
- JS inclusion only if powermail plugin on same page

Idea:
Using a userFunc in a condition

Todo 1:
ext_typoscript_setup.txt old:
# Add Javascript files to page header if a powermail plugin is on current page
page.includeJS.file31311 = EXT:powermail/js/checkbox/checkbox.js
page.includeJS.file31312 = EXT:powermail/js/mandatoryjs/lib/prototype.js
page.includeJS.file31313 = EXT:powermail/js/mandatoryjs/src/effects.js
page.includeJS.file31314 = EXT:powermail/js/mandatoryjs/fabtabulous.js

page.headerData.31310 = TEXT
page.headerData.31310 {
    wrap = <script src="|" type="text/javascript"></script>
    typolink.parameter.data = page : uid
    typolink.additionalParams = &type=3131
    typolink.addQueryString = 1
    typolink.returnLast = url
}
seite.headerData.31310 < page.headerData.31310
seite.includeJS.31311 < page.includeJS.file31311
seite.includeJS.31312 < page.includeJS.file31312
seite.includeJS.31313 < page.includeJS.file31313
seite.includeJS.31314 < page.includeJS.file31314
ext_typoscript_setup.txt new:
# Add Javascript files to page header if a powermail plugin is on current page
[userFunc = user_powermailOnCurrentPage]
page.includeJS.file31311 = EXT:powermail/js/checkbox/checkbox.js
page.includeJS.file31312 = EXT:powermail/js/mandatoryjs/lib/prototype.js
page.includeJS.file31313 = EXT:powermail/js/mandatoryjs/src/effects.js
page.includeJS.file31314 = EXT:powermail/js/mandatoryjs/fabtabulous.js

page.headerData.31310 = TEXT
page.headerData.31310 {
    wrap = <script src="|" type="text/javascript"></script>
    typolink.parameter.data = page : uid
    typolink.additionalParams = &type=3131
    typolink.addQueryString = 1
    typolink.returnLast = url
}
seite.headerData.31310 < page.headerData.31310
seite.includeJS.31311 < page.includeJS.file31311
seite.includeJS.31312 < page.includeJS.file31312
seite.includeJS.31313 < page.includeJS.file31313
seite.includeJS.31314 < page.includeJS.file31314
[end]
Todo 2:
Add a new file to the powermail lib folder which is called user_powermailOnCurrentPage.php:
<?php
function user_powermailOnCurrentPage() {
    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery ( // DB query
        'uid',
        'tt_content',
        $where_clause = 'pid = '.$GLOBALS['TSFE']->id.' AND CType = "powermail_pi1" AND hidden = 0 AND deleted = 0',
        $groupBy = '',
        $orderBy = '',
        $limit = 1
    );
    if ($res) {
        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); // Result in array
        if ($row['uid']) return true;
    }
    return false;
}
?>
Todo 3:
Add a new line to the ext_localconf.php of powermail:
include_once(t3lib_extMgm::extPath('powermail').'lib/user_powermailOnCurrentPage.php'); // Conditions for JS including

2008-12-21 14:34 - Alex Kellner

  • Status changed from Accepted to Resolved

Resolved in 1.4.3

2008-12-22 16:04 - Nikolas Hagelstein (pulponair)

Alex Kellner wrote:

Resolved in 1.4.3

user_powermailOnCurrentPage should make use of enableFields in order to account for "start/endtime" and workspace issues.
The enableFields can be easily accessed from within user functions using $GLOBALS['TSFE']->sys_page->enableFields(...). So there is no need to instance a cObj. Execept for that: good solution :)

2009-01-08 15:06 - Alex Kellner

  • Status changed from Resolved to Accepted

Hi Nikolas,

have a look to this thread:
http://www.typo3.net/forum/list/list_post/x/85572/

Using $GLOBALS['TSFE']->sys_page->enableFields('tt_content') seems not to work on all installations

Greetings, Alex

2009-01-11 14:53 - Alex Kellner

  • Status changed from Accepted to Resolved

Fixed in current version - I don't want to reopen this issue again :)

Also available in: Atom PDF