AbanteCart Development > General Extensions

Placing Asynchronous scripts globally

(1/4) > >>

Nimitz1061:
I've been looking at the developers documentation.

We need to place an asynchronous script (two separate script tags, one initializing things for the other, which provides the final service).    The method provided for placing scripts seems to only support adding scripts into the header.

Am I missing something here??

David

abolabo:
hello.
1. You can place scripts from controller.
2. You can pace "script" tags in your tpl-file.
1st way is prefer.

If you want to place scripts globally you can add it into common/head (php or tpl) file.

i don't know what you doing but if you working on template you can hook controller common/head.php.
for ex. your extension calls mytemplate:
1. create file with hook in directory mytemplate/core/hook.php and include it into main.php
--- Code: ---(if(!class_exists('ExtensionMyTemplate')){
include('core/hook.php');
})
--- End code ---
2. place there hook something like this

--- Code: ---class ExtensionMyTemplate extends Extension {
   
     public function onControllerCommonHead_UpdateData() {
$registry = Registry::getInstance();
$registry->get('document')->addScript($this->view->templateResource('/javascript/global_scripts/myscript.js'))
    }
}
--- End code ---

Nimitz1061:
This places a single script into the head of the page.

An asynchronous script is split into two (or more) script blocks at least one of which is placed in the foot of the page. (ie, just before the closing of the body).

Also, there are many instances in which placing a script at the bottom of the page is desirable.  I don't see a method which will accomplish this.

David

abolabo:

--- Quote from: Nimitz1061 on July 23, 2012, 06:49:28 AM ---This places a single script into the head of the page.

An asynchronous script is split into two (or more) script blocks at least one of which is placed in the foot of the page. (ie, just before the closing of the body).

Also, there are many instances in which placing a script at the bottom of the page is desirable.  I don't see a method which will accomplish this.

David

--- End quote ---

sorry, but i don't understand what's problem.
First script adds to head.
Second  script tag  - into common/page.tpl before body tag close.

 

Nimitz1061:
I should add that global means global.  Happening on every page, in every template no matter what.

Analytics, for example,  is not a template related activity, and we need to not lose the script because someone choses a different template or layout.  We also need to assure that the blocks placed for global features are not deleted or removed from display.

Navigation

[0] Message Index

[#] Next page

Go to full version
Powered by SMFPacks Social Login Mod