PHP Classes

File: plugins/html_ul/plugin.php

Recommend this page to a friend!
  Classes of P. Krijnberg   Expose template engine   plugins/html_ul/plugin.php   Download  
File: plugins/html_ul/plugin.php
Role: Auxiliary script
Content type: text/plain
Description: Unordered List plugin (This is an example explaining how to write your own plugins).
Class: Expose template engine
Template compiler engine extensible with plug-ins
Author: By
Last change: role
Date: 19 years ago
Size: 1,572 bytes
 

Contents

Class file image Download
<?php
// This is an example explaining how to write your own plugins.
//

// If you want to have your plugins automatically registered:
// - create a directory inside plugins/ and name it the same as your plugin
// - this file should be saved as plugins/<plugin name>/plugin.php
// - the plugin function should be named expose_plugin_<plugin name>
// and accept two parameters: a reference to the Expose object and an
// array containing the parameters as they were given in the template
// calling this plugin.
//
function expose_plugin_html_ul( & $expose, $params )
{
// The $params parameter is transformed by exposeMergeParameters(). Plugins
// should always use this function. It will make sure the plugin works when
// not all parameters were given or when the template uses unnamed or a mix
// of named and unnamed parameters.
//
   
$params = exposeMergeParameters( $params, array(
       
'items' => array(),
       
'attr' => ''
   
) );
   
// exposeReadArray() is used to allow comma-separated strings to be used
// instead of an array.
//
   
$params['items'] = exposeReadArray( $params['items'] );
   
// Print the results to the browser. Instead of printing the results, you can
// alternatively return the result as a string by building the string in
// a variable first and using the return statement.
//
   
echo( "<ul {$params['attr']}>\n" );
    foreach(
$params['items'] as $item ) {
        echo(
"\t<li>$item\n" );
    }
    echo(
"</ul>\n" );
}
?>