>> Table of Contents >> Developer's Manual

Miscellaneous functions

How do I call an action of another plug-in?

To handle actions YANA provides the function $YANA->handle(), which returns bool(true) on success and bool(false) otherwise.

<?php 
global $YANA;

/* call action "foo" */
$bool $YANA->handle("foo"$parameter);
if ($bool) {
    print "The action 'foo' has been executed successfully.";
} else {
    print "The call of 'foo' returned an error.";
}
?>

How do I empty the template cache of the server?

This causes all files in the directory "cache/" to be deleted.

<?php 
global $YANA;

/* empty server's template-cache */
$YANA->handle("clear_server_cache", array());
?>

How do I create a preview for an entry, eg. in a forum?

<!-- The following entry in the template is already enough: -->
<textarea id="inputfield" name="text"></textarea>
[%preview%]

Screenshot
Figure: Example of the representation in the Browser

How do I create "micro-summaries" for Firefox 2.0 and higher?

"Micro Summaries" are "active bookmarks", meaning hyperlinks, whose text can be dynamically updated when the content of the website changes, to which the link points. The Firefox browser offers Micro Summaries automatically, if the user creates a bookmark of a page that has that feature.

Examples of this would be:

Other variants are of course possible.

Micro Summaries are supported by the Yana Framework. They are created using the utility-class "Micro Summary". Take a look at the following examples:

<?php 
/* creating a mirco-summary in your plug-in */
Microsummary::set($this->name'link text');

/* Please note:
 * The first parameter is an unique id,
 * which identifies the entry.
 * Here: $this->name is used as id,
 * because the name of the plug-in is unique.
 * However, it is possible to use any other text.
 * For example, when you want to create multiple entries for the
 * same plug-in.
 */

/* reading a micro-summary in your plug-in */
$microsummary Microsummary::get($this->name);

/* publishing a micro-summary in your plug-in,
 * so that the browser can find it, when viewing the page
 */
Microsummary::publish($this->name);

/* To open the micro-summary in your browser: */
index.php?action=get_microsummary&target=guestbook

/* For testing, the URL must be copied to your browser.
 * The argument "target" names the id of the micro-summary you want to view.
 */
?>

How do I create RSS feeds?

"RSS-Feeds" are electronic, (mostly) automatically generated and updated lists, which may provide various information. A visitor may read these with any "RSS reader" software. Modern browsers already have this functionality built in, so that visitors no longer need additional software.

Examples for RSS-Feeds:

The Yana Framework supports the creation of RSS feeds for your applications. Therefor you can use the prepared classes "RSS" and "RSSitem". The following are some examples.

<?php 
/* To create a RSS feed for your plug-in, first create a new function.
   (Change the name as you see fit. Note that the name must be unique.) */
function my_rss_feed($ARGS)
{
    $rss = new RSS();
    // choose a title and description
    $rss->title 'Mike Miller\'s News';
    $rss->description 'this is my RSS feed for my web site';
    // add an entry
    $item = new RSSitem();
    $item->title 'Entry 1';
    $item->link 'http://any.url';
    $item->description 'A short text, describing the content, or a text excerpt.';
    // add the entry to the RSS feed
    $rss->addItem($item);
    // a 2nd eintry
    $item = new RSSitem();
    $item->title 'another item';
    $item->link 'http://any.other.url';
    $item->description '2nd description';
    $rss->addItem($item);
    // output the RSS feed to the browser
    print utf8_encode($rss->toString());
    exit(0);
}

/* You can have a link to the RSS feed viewed in the application.
   To do so use the function RSS::publish() and the name of the function,
   that creates the RSS feed.
   Tip: The best place to do this is is the constructor
   of your plug-in.*/
function plugin_my_test($name)
{
    RSS::publish('my_rss_feed');
    // more source code may follow here
}
?>

Author: Thomas Meyer, www.yanaframework.net