You are here: Documentation > JYAML for Joomla! 1.5 > Template-Plugins > Template-Plugins

Template-Plugins

The YAML-Joomla!-Template has a own plugin management for special expansions. All Template-Plugins can get global as well as configured in every single design.

The control of the Plugins takes the JYAML-System-Plugin for Joomla!.

If one has knowledge of PHP, you can even develop their own plugins and add.

Core-Plugins

Are already one of couple of Plugins, too. Following a listing:

  • IE PNG Fix:  Transparent PNG makes pictures possible in the Internet Explorer 5.5 and 6,
  • IE min/max Expressions: Simulate min-/max width and height in the Internet Explorer 5 and 6,
  • CSS Optimizer: Reduction and clearing up of the CSS files for the reduction of TRAFFIC and enquiries.

Developing you own Plugins

All Template-Plugins are in the directory /templates/[YAML template] /plugins. Followingly one example to create own plugins. Create a folder in the plugin directory with the desired name of the plugin. A name is used as in this example "my_yaml_plugin".

Step 1:

Files following now must be create in the plugin folder. These are also at least required.

  • my_plugin.xml (Parameter file. Built up to the Joomla!1.5 XML-Referenz).
  • my_plugin.php (Executable PHP file for the control of the plugins).
  • config.xml ( The configuration values are stored here later).

Step 2:

Laying out the contents of the my_plugin.xml.

<?xml version="1.0" encoding="utf-8"?>
<jyaml_plugin>
  <name>my_plugin</name>
  <author>My Name</author>
  <creationDate>Create Date</creationDate>
  <copyright>(C) My Name</copyright>
  <license>Creative Commons Lizenz</license>
  <authorEmail>myEmail[AT]domain.tld</authorEmail>
  <authorUrl>www.myDomain.tld</authorUrl>
  <version>1.0</version>
  <description>Description</description>

  <!-- As of here becomes the Joomla! parameter XML-Referenz used  -->
  <params>    
    <!-- 
    The Value 'published' with '0' and '1' is at least required, 
    since otherwise one cannot switch on the Plugin. 
    -->

    <param name="published" type="radio" default="0" label="Aktiviert?">
      <option value="0">Nein</option>
      <option value="1">Ja</option>
    </param>
    <param name="text" type="text" default="" label="Text" />
    <!-- *** -->
  </params>
</jyaml_plugin>

For broader possibilities of the parameters ("param") you search in the Joomla!1.5 XML-Referenz list.

Step 3:

Laying out the contents of the my_plugin.php.

// kein direkter Zugriff auf die PHP Datei
defined('_JEXEC') or die('Restricted access');

//  Diese PHP-Klasse wird direkt zur Laufzeit des YAML-System Plugins ausgeführt
class my_plugin extends JYAML {

var $JYAML = array(); // can overwrite share $jyaml object
var $JYAMLc = array(); // can overwrite share of $jyaml->config object

  function my_plugin($params, $jyaml) {
    $document=& JFactory::getDocument();    
    if($document->getType() != 'html') {
      return;
    }  
    
    // Fügt ein Javascript in den HEAD des Dokuments
    $jyaml->addScript( JYAML_PATH_REL.'/plugins/my_plugin/example.js' );
    
    /* 
       ... 
       usw. 
       ...
    */
  }
/*
Diese Klasse (mit Zusatz _afterRender) wird ausgeführt wenn das gesamte
Dokument bereits fertig für die Ausgabe aufbereitet ist, aber noch
nicht von Joomla! ausgegeben wurde. Somit sind spezielle Anpassungen am
Dokument möglich
*/
class my_plugin_afterRender extends YAML {

  function my_plugin_afterRender($params, $jyaml) {
    $document=& JFactory::getDocument();    
    if($document->getType() != 'html') {
      return;
    }

    // Lese Parameter Konfiguration
    $text= $params->get( 'text', 'kein Text vorhanden' );    
        
    // Dokument Body auslesen
    $body = JResponse::getBody();
   
    // Den Body modifizieren
    // Als Beispiel wird ein Absatz direkt hinter <body> hinzugefügt.
    $body = str_replace('<body>', '<body><p>'.$text.'</p>', $body);     

    // Den neuen Body Inhalt übergeben    
    JResponse::setBody($body);
  }

}

In the Template-Plugins all oomla! functions can are used. You read the Joomla! documentation Wiki to this. In addition, you can call the $jyaml PHP-Object and its methods for disposal in addition.

Step 4: Aktivation you own Plugin 

If all required files are created now, you can your own Template-Plugin see in the backend of the JYAML-Component. It can be now activated if the at least required parameter 'published' is existing in the my_plugin.xml

Step 5: Contribute

If you develop plugins of your own or have only an idea, then simply let me know anyway and contact me.