New Classes for WBCE CMS,  1.4.1
Documentation for all new Classes in WBCE CMS
Inserting JS, CSS, Metas and more into the pagetemplate.

Table of Contents

This article is about the basic usage of class I a static facade for class Insert that does the actual work.

The purpose of these two classes is the insertion of Javascript, Metas, Title and CSS into a pagetemplate on WB and maybe other systems.
In WB this class we use the global facade (class I) to guarantee a fully global presence.

This is done by:

For more detailed information about how to use this thing whith WB have a look into the documantation of the facade class I(facade).

If you are intrested in the class details, want to use the insert class whithout the facade or want some internals have a look at Insert.

Attention
Modulebuilders only need to look at class I and only the Add...() methods maybe Get..() methods anything else is more or less core developers only.

Back Up

Adding elements to the queue

Javascript

Adding a script file

I::AddJs (array(
'position'=>"BodyLow",
'src'=>"https://code.jquery.com/jquery-2.1.4.min.js"
));

possible: positions are HeadTop, HeadLow, BodyTop, BodyLow.
src: the url to the file

Back Up

Adding a script

I::AddJs (array(
'position'=>"HeadLow",
'script'=>"alert('script added');",
));

script: The script you like to add (maybe some settings for your colorbox or whatever)

Back Up

Metas

$i->AddMeta(array (
"name"=>"description",
"content"=>"This is a nice description"
));
// <meta name="description" content="This is a nice description" />
// In an international enviroment
$i->AddMeta(array (
"name"=>"keywords",
"content"=>"This, Description, Something",
"lang"=>"en"
));
// <meta name="keywords" content="This, Description, Something" lang="en" />
// charset
$i->AddMeta(array (
"charset"=>"ISO-8859-1"
));
// depending on render method this will produce very different output
// html : <meta http-equiv="content-type" content="text/html; charset=utf-8">
// xhtml: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
// html5: <meta charset="utf-8">

Back Up

CSS

Adding a CSS file.

// adding font awesome
$i->AddCss (array(
'href' =>"https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css",
'media' =>"screen"
));

Back Up

Adding some direct style commands.

$i->AddCss (array(
'style' =>"#htto {position:absolute}"
));

Back Up

Allowed Keys

    Key         Typ         Description  
    --------------------------------------------------------------------------------------------------
    href        string      Simply the full URL where to load the Script
    style       string      The plain style definitions to insert.
    media       string      The "media" attribute for stylesheets.
    title       string      "title" atribute NOT IMPLEMENTED YET! 

Back Up

Title

Simply adding a title or even overwrite the old one.

I::AddTitle ("My Cool Website");
//renders as "\t<title>My Cool Website</title>"
I::AddTitle (" - Page Introduction");
//renders as "\t<title>My Cool Website - Page Introduction</title>"
I::AddTitle ("A far mor important title", true);
//now renders as "\t<title>A far mor important title</title>"

Back Up

The Template

The Template should look like this.

<!DOCTYPE html>
<html lang="de">
<head>
[[Metas]]
[[Title]]
[[Css]]
[[Js?pos=HeadTop]]
[[Js?pos=HeadLow]]
</head>
<body>
[[Js?pos=BodyTop]]
<!-- Sichtbarer Dokumentinhalt im body -->
<p>Sehen Sie sich den Quellcode dieser Seite an.
<kbd>(Kontextmenu: Seitenquelltext anzeigen)</kbd></p>
[[Js?pos=BodyLow]]
</body>
</html>

Back Up

More details

For a more detailed description please look into the documentation of Class I(facade)

Back Up