Pixelpost

Authentic Photoblog Flavour

ExtendingPixelpost /

ExtendingPixelpost.AdminHelloWorldAddon History

Hide minor edits - Show changes to markup

November 06, 2007, at 05:56 AM by austriaka -
Changed lines 54-55 from:
to:

?>@]

November 05, 2007, at 02:29 PM by austriaka -
Added lines 1-55:

Admin Hello World Addon Code

file admin_hello_world.php

(:source lang=PHP -link :)
<?PHP
// This is a basic example for several methods of including admin addon functions into existing and new pages.
// To see it run save it as "admin_hello_world.php" into your Addons folder.
// Open the Admin Addons page, look out for the Admin 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 = 'Admin Hello World Addon';
// Addon Description (we use it for a little form here):
$addon_description = 'This is a sample addon for creating a Hello World Menu and a few Hello World Submenus.<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 on the Hello World Page').'" name="hello"> <input type="submit" value="Remember">
</form>';
// Addon Version:
$addon_version = "0.1";

// Just always remember the Admin Interface function:
// add_admin_functions($addon_function_name,$addon_workspace,$addon_menu,$addon_admin_submenu);

// First we use the Admin Interface to place the Helloworld text into an existing page, the General Info page for example:
add_admin_functions('say_hello','info','','');
// have a look into the General Info page now!

// Now we want to create a new submenu page to an existing menu entry, the Options page perhaps:
// add_admin_functions($addon_function_name,$addon_workspace,$addon_menu,$addon_admin_submenu);
add_admin_functions('say_hello','options','options','HelloWorld');
// great fun, isn't it?

// Last thing we create is a brand new menu page for our Hello World:
add_admin_functions('','admin_main_menu','HelloWorld','');
// and fill it with content:
add_admin_functions('say_hello','admin_main_menu_contents','HelloWorld','');
// hey, that is cool!

function say_hello()
{
	echo "<div id='cropdiv'>
		<table width='300' height='50' border='1' cellpadding='10' cellspacing='0' bordercolor='red' align='center'>
			<tr>
			<td><H3>".$_SESSION['sayhello']."</H3></td>
			</tr>
		</table>
		<br />
	</div>";
}// end function
?>

«HelloWorldAddon|Admin Addons|FrontHelloWorldAddon»


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