In version 1.5 of Pixelpost, team Pixelpost has introduced a new feature, called Admin-Addon, that extends the flexibility and functionality of the Pixelpost software. With this new feature people can simply use addons and plugins to add new new function inside the Admin-Panel of Pixelpost. Read this article to get a better understanding of this new useful feature.
Basically, Pixelpost accepts addons for adding custom functionality to its simple behavior. Before the release of Pixelpost 1.5, addons were only able to add new feature to the visitors side of a photoblog. However, since version 1.5, addons can be used to add new functionalities to the Admin-Panel side, where admin user manages the photoblog. This realizes the dreams that the simple Pixelpost software could perform complex behaviors with some customizations. People now can use addons in the Admin-Panel to have more options in posting an image, editing previously posted photos, having more options, and even adding new pages to the Admin-Panel. This new type of addons is called Admin-Addon.
Only Pixelpost 1.5 or above supports the Admin-Addons feature.
With Admin-Addons you can
How does Admin-Addon work?
The logic behind the Admin-Addons are simple and once you get knowing it, you can write Admin-Addons even with one hand tied behind your back! Once admin user visits the admin pages and logs in, the script looks into the addons folder for the admin-addons and updates the list of available addons in the addons' table. Thereafter it will gather a list of functions from addons and their corresponding workspaces in an array. Consequently, at every workspace/anchor in run-time it will call the related functions from admin-addons.
By considering the usage, the related functions can be categories in 5 different groups.
Functions for extending the HTML code between <head> and </head> tags in admin pages.
Simple functions that don't need menu and submenus.
Function that act in menus or submenus.
Functions that add new menu items to admin area.
Functions that add new page content to admin area.
All of the above different types of functions will be assigned through a single interface. The interface is the function named add_admin_functions().
Below, the syntax for using the interface function is decribed:
add_admin_functions ($function_name as string ,$workspace as string ,$menu as string ,$admin_submenu as string );
Syntax | Description | |
1 | add_admin_functions ($function_name,'admin_html_head','',''); | This can be used to echo some additional HTML codes into the place between <head> and </head> inside all page of admin area. For instance, the function with name as string in variable $function_name, could have simple code like: echo '<script language="javascript" type="text/javascript">somescript code... </script>'; |
2 | add_admin_functions ($function_name,$workspace,'',''); | This can be used to assign a function (with name as string in variable $function_name) to a predefined workspace ($workspace as string) in the admin code without setting a specific menu or submenu for it. The second and third arguments are set to empty strings. |
3 | add_admin_functions ($function_name,$workspace,$menu,$submenu); | This will can be used to assign a function to the place in the code that user has selected a menu and/or submenu in the admin area. If you pass only menu string and leave submenu variable string as an empty string the function will be called just when menu is selected. If both menu and submenu strings are set the function will directly called when the submenu of the selected menu is visited. If the submenu you mention in this function does not exist in the package it will create that submenu automatically. The list of available menu and submenus is provided below this table. |
4 | add_admin_functions ('','admin_main_menu',$menu,''); | This function call will create a new menu item with a link to a newpage. The $menu variable will indicate the title of the page in the menu as well as the link to that new page in the admin area. For instance if $menu is newitem, the link to the new page will end with index.php?x=newitem. |
5 | add_admin_functions ($function_name,'admin_main_menu_contents',$menu,''); | This function call will assign a function to print the content of a new page with name specified in $menu variable as string. The function with the name as string inside $function_name variable should will be called when the menu item as $menu is selected. |
Here is the list of available Menu/Submenus of Pixelpost 1.5 that can be used for Admin-Addons
menu name | menu variable string | submenu name | submenu variable strings | link |
New Image | - | - | - | index.php |
Options | options | General | general | index.php?x=options&optionsview=general |
Options | options | Template | template | index.php?x=options&optionsview=template |
Options | options | Thumbnails | thumb |
index.php?x=options&optionsview=thumb |
Options | options | Spam Control | antispam | index.php?x=options&optionsview=antispam |
Options | options | <custom submenu> | <customsubmenu> | index.php?x=options&optionsview=customsubmenu |
Images | images | - | - | index.php?view=images |
Images | images | <custom submenu> | <customsubmenu> | index.php?view=images&imagesview=customsubmenu |
As it is presented in the above table with a distinct color, if you want to add new submenus to images or options page the link these pages will be automatically created as index.php?view=images&imagesview=customsubmenu and index.php?x=options&optionsview=customsubmenu respectively where you can replace the "customsubmenu" with the name of your choice.
How to write Admin-Addons?
There is a sample admin-addon named Admin_12CropImage that adds the cropping ability for creating thumbnails after uploading a new image or even when editing an old post.
There are some detailed instructions for writing an admin addon (addons/admin_12CropImage.php).
Key points are:
You can write separate functions for different places of the Admin-Panel. These function can be called in the proper place and the only thing you need to do is to assign each function to some predefined places in the code. These predefined places are called workspaces which anchors to some places inside Admin-Panel codes. With assigning new functions to each of these anchors you may get new functionalities in different parts of the code.
Below is a part of the sample admin addon that assigns a custom function, cropimage12_admin_addon, to a predefined place, image_edit, which is actually the page that admin visits when it has to edit a post.
This addon adds a submenu to the edit image page and thus, the menu name for this new submenu is specified as
To add new pages to Admin-Panel and add new menu and submenus you should take following steps:
First to add the name of the new page to the menu
// add the function
$addon_workspace = 'admin_main_menu_contents';
$addon_function_name = 'new_item_show_page';
$addon_admin_submenu = "";
$$addon_menu = "NEWITEM";
add_admin_functions($addon_function_name,$addon_workspace,$addon_menu,$addon_admin_submenu);
// the function to act on the new page
function new_item_show_page()
{
global $addon_admin_functions;
global $pixelpost_db_prefix;
if ($_GET['view']=='newitem'){
echo "
<div class='caption'>
NEWITEM
</div>
<div class='jcaption'>
Some Section Title...
</div>
";
}
<?php
// add the new page title to the main menu
$addon_workspace = "admin_main_menu";
$addon_menu = "NEWITEM";
add_admin_functions('',$addon_workspace,$addon_menu,'');
// assign a function name to make the content of the new page
// add the function
$addon_workspace = 'admin_main_menu_contents';
$addon_function_name = 'new_item_show_page';
$addon_admin_submenu = "";
add_admin_functions($addon_function_name,$addon_workspace,$addon_menu,$addon_admin_submenu);
// the function to write the content of the new page
function new_item_show_page()
{
global $addon_admin_functions;
global $pixelpost_db_prefix;
if ($_GET['view']=='newitem'){
echo "
<div class='caption'>
NEWITEM
</div>
<div class='jcaption'>
Some Section Title...
</div>
";
echo "<p/> This is really a <b>new page</b>!!";
}// end if
}
?>
$submenucssclass = 'selectedsubmenu';
else if (!isset($_GET['newitemview'])) $submenucssclass = 'selectedsubmenu';
echo "
<a href='?view=newitem&newitemview=info' id='infoselected' class=".$submenucssclass." >Info</a>
";
$submenucssclass = '';
if (isset($_GET['newitemview']) && ($_GET['newitemview']=='moderate' ))
$submenucssclass = 'selectedsubmenu';
echo "
<a href='?view=newitem&newitemview=moderate' id='moderateselected' class=".$submenucssclass." >Moderate</a>
";
$submenucssclass = '';
if (isset($_GET['newitemview']) && ($_GET['newitemview']=='edit' ))
$submenucssclass = 'selectedsubmenu';
echo "
<a href='?view=newitem&newitemview=edit' id='editselected' class=".$submenucssclass." >Add/Remove Photos/Icon</a>
";
echo "</div>";
// .. the rest of the code
}
Can I add new menu items and tabs to Pixelpost Admin-Panel with Admin-Addons?
yes, read "How to write Admin-Addons"
Workspace Name |
Menu Name | file/ near line | Description |
image_edit |
images | images_edit.php/267 | Place that executes the code when admin tries to edit an image. Useful when you want to add new submenus to the image edit page. Admin_12CropImage sample addon uses this workspace. |
image_edit_form |
images | images_edit.php/274 | To add any new input to the form for the editing of an individual image. |
image_update |
images | images_edit.php/73 | Place that executes the code when admin updates an image via the editing page. Useful when adding new functions to editing images. |
image_deleted | images | images_edit.php/120 | Place that executes the code when admin deleted an image. Useful when you want to add new submenus to the image edit page. |
admin_html_head | - | index.php/187 | Executes when code is producing HTML to be placed between <head> and </head> tags and will work for every page of Admin-Panel. |
admin_main_menu | - | index.php/244 | Place that executes the code to automatically produce the menu items. |
admin_main_menu_contents | - | index.php/271 | Place that executes the code to show the contents of every new page in the Admin-Panel. |
new_image_form | - | new_image.php/127 | To add any new element to the HTML form in the New Image page you can use this workspace. |
image_uploaded | - |
new_image.php/228 |
A part of code that will execute JUST after the successful uploading of an image. |
thumb_created | - | new_image.php/255 | A part of code that will execute right after uploading a new file and the creation of the thumbnail image. This is useful when you want to add new tools or information after file upload. For example, Admin_FlashCrop addon uses this to let you crop the image for creation of a thumbnail in a Flash screen below the uploaded page. |
options | options | options.php/186 | A part of code which executes when admin browses to the options page. You may use this to create new option pages with submenus to the option page. |
info | info | view_info.php/16 | A part of code which executes when admin browses to the general info page. You may use this to create new general info pages with submenus to the general info page. |
image_list |
images | images_edit.php/330 | Place that executes the code for each image in the image overview of "images". Useful if you want to add new information for each image in the image list. |
image_upload_start |
images | new_image.php/279 | Place that executes the code before the image is actually moved to the images folder when uploading an image. |
image_upload_succesful |
images | new_image.php/279 | Place that executes the code when the uploading of an image was succesful.(Note: this is similar to "image_uploaded" workspace but for sake of compatibility both workspaces remain active.) |
image_upload_failed |
images | new_image.php/279 | Place that executes the code when the uploading of an image failed. |
image_reupload_start |
images | images_edit.php/206 | Place that executes the code before the image is actually moved to the images folder when reuploading an image. |
image_reupload_succesful |
images | images_edit.php/219 | Place that executes the code when the reuploading of an image was succesful. |
image_reupload_failed |
images | new_image.php/424 | Place that executes the code when the uploading of an image AND the creation of a thumbnail have finished. |
upload_finished |
images | images_edit.php/237 | Place that executes the code when the reuploading of an image failed. |
new_image_form_def_lang |
images | new_images.php/237 | Show more options when uploading a file (default language). |
new_image_form_alt_lang |
images | new_image.php/189 | Show more options when uploading a file (alternative language). |