Skip to content
voltan edited this page Jul 16, 2011 · 5 revisions

What is Applets

Applet is a special type of block or widget, no need of installation.

How I can use Applets in my theme or apps ?

Whit this smarty code :

<{widget name="applet-name-you-have"}>

How I can write a applet ?

It's very easy you must do this Steps:

1. Creat a php file whit your applet name : for example twitter.php

###2. Put this file in to /usr/applets/ ###3. Add the code like this in your file `namespace Applet;

class Twitterfollow extends \Application\Applet { public function render() {
return $this->twitter(); } protected function img() { $image = 'follow_me-a.png'; $pach = 'img/images/twitter/'; $img = \XOOPS::url($pach.$image); return $img; } protected function url() { $account = 'XoopsProject'; $url = 'http://www.twitter.com/'. $account; return $url; } protected function alt() { $alt = 'Follow XoopsProject on Twitter'; return $alt; } protected function twitter() { $twitter = " ".$this->alt()." "; return $twitter; } } `

###4. you have to add this part in top of your file for load applets

namespace Applet;

###5. after that you have to add class like this :

class YOURCLASSNAME extends \Application\Applet { ..... }

###6. you need render public function like this :

public function render() { ..... }

###7. if you need other functions you can put all functions in your class as protected function