Bienvenue sur Geeklog France, anonyme 19 avril 2019 - 20:57

 05 mars 2011 - 19:26 (Lu 7627 fois)  

Status : hors ligne



Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
Une nouvelle class sera prochainement disponible

PHP Formatted Code

Here are some highlights of the class:

-       When the class is used, only the JavaScript and CSS files that are
needed will load
-       Admin can specify to use Google's CDN files for jQuery
-       Class will fall back and use Google'
s CDN files if jQuery files
missing from Geeklog
-       Will do away with inline scripting (ie scripts in template files) as
you will now pass the required Javascript to the class
-       Can specify to load JavaScript in header or footer (defaults to
footer and jQuery always loads in the footer)
-       Possible future feature includes Caching/Compressing of regularly
included JavaScript Files and CSS files (hence the unused constant variable
in some of the classes functions)

The class is set near the beginning of lib-common.php as $_SCRIPTS. It uses
the template variable plg_headercode in COM_SiteHeader to put information in
the header and COM_SiteFooter with plg_footercode to put JavaScript in the
footer. Obviously all your JavaScript code (and CSS files) needs to be set
in the class before COM_SiteHeader is run (at least for the CSS files and
any JavaScript in the header). All JavaScript must be set by the time you
call COM_SiteFooter (this shouldn't be a problem since this is one of the
last functions you should be calling anyways on a page).

So how do you use the new class?

To pass in some JavaScript code and a JavaScript file to the footer you
would do something like so:

               // Add JavaScript
               $js = '
geeklogEditorBasePath = "' . $_CONF['site_url'] .
               $_SCRIPTS->setJavaScript($js, true);

Or if you wanted to tell Geeklog to include a jQuery library


Or to use a widget of the jquery ui plugin


If you tell the script to use a widget there is no need to tell the Scripts
class to load jQuery as it will automatically add it in.

To add a CSS file you would do something like this

theme', $theme_path . '/style.css');

If JavaScript is included in any page a bunch of Core JavaScript variables
will automatically be inserted for use by any JavaScript code that needs
them. These variables are geeklogSiteUrl, geeklogLayoutUrl, geeklogAdminUrl
and geeklogThemeName.

Finally, the order of placement for JavaScript in the footer is

1. Core JavaScript variables
2. JavaScript Library files (jQuery, etc..)
3. JavaScript Code (from setJavaScript)
4. JavaScript Files (from setJavaScriptFile)


Le fuseau horaire est CEST. Il est maintenant 08:57 .

  • Sujet Normal
  • Sujet important
  • Sujet clos
  • Nouvelle Contribution
  • Nouveau sujet important
  • Nouveau sujet clos
  • Vous pouvez lire ce forum 
  • Les anonymes peuvent dans ce forum 
  • HTML autorisé 
  • Contrôle vocabulaire