Pixelpost

Authentic Photoblog Flavour

ExtendingPixelpost /

Front Hello World Addon Code

file front_hello_world.php

<?PHP
// This is a basic example for writing a front addon which makes use of the front workspace "frontpage_init".
// To see it run save it as "front_hello_world.php" into your Addons folder.
// Open the Admin Addons page, look out for the Front Hello World Addon and enter some text here ("Hello World" would be fine).
// Read through these Addon comments and see what happens

// First perform the action of Addons page form
if ($_GET['view']=='addons' && $_GET['say']=='hello') {
         $_SESSION['sayhello'] = $_POST['hello'];
}

// Now the part which has always to be here:
// Addon Name:
$addon_name = 'Front Hello World Addon';
// Addon Description (we use it for a little form here):
$addon_description = 'This is a sample addon for writing a Front Addon which uses a front workspace.
<br /><br />
<form action="'
.$_SERVER['PHP_SELF'].'?view=addons&amp;say=hello" method="post" accept-charset="UTF-8">
<input type="text" size="50" value="'
.($_SESSION['sayhello']?$_SESSION['sayhello']:'Enter a text here, it will be shown instead of the tag &lt;HELLO_WORLD&gt; in your image page').'" name="hello"> <input type="submit" value="Remember">
</form>'
;
// Addon Version:
$addon_version = "0.1";

// Just always remember the Front Interface function:
// add_front_functions($addon_function_name,$addon_workspace);

// We use the Front Interface to place the Helloworld text right after a comment is stored in the database:
add_front_functions('say_hello_front','comment_accepted','','');

function say_hello_front() {
        $hellotext = '<H2>This is my front text:<br />'.$_SESSION['sayhello'].'</H2>';
        echo $hellotext;
}
// To see it working just write a comment in your blog and you will see it in the Thankyou page.
// Not so beautiful because it is set before the DOCTYPE declaration but this is only for testing purpose.
// Never use it in your real blog ;-)
?>

TOP << FrontWorkspaces | ExtendingPixelpost | >>


Page last modified on November 06, 2007, at 05:57 AM