Aug 22, 2008 | 05:11 PM  
Welcome

Don't have an account yet? You can create one, it is free, just click here

as a registered user you have some advantages like free downloads, comments and posting on our forums, depending upon this site's configuration and options.

 • •  Control Panel - Register - Login  • • 
Current Stable MDPro Lite 1.0821 Download
   19-Oct-2005  Print current page  Show map

API Command Reference

Duster

The PostNuke API is a work-in-progress. There will be many functions that are missing from the API that developers would like. To this end, if a developer has a request for a particular function then they can submit it to the MDPro features request list on SourceForge at the PostNuke Homepage. The same system can be used for sending in updates of current functions or new functions. If you are a developer and currently either globals directly or accessing one of the core tables to obtain or update information then please consider sending in a feature request so that the MDPro team can develop an API to carry out the work instead. This will ensure that your code is more likely to continue working through future versions of MDPro without modification, and that

Please note that the main requirements for the core PostNuke API are stability and a relatively small footprint. Due to this it is possible that your request for a new or updated function will get refused on the grounds that it is too specific or can easily be built from other core API functions. In such situations the MDPro team will always try to provide a simple alternative, but please remember that submission of a new or updated part of the API does not guarantee inclusion.

The PostNuke API is broken down in to a number of different areas. These areas are as follows:

Throughout the API reference, use is made of a type void, especially for specific return values. PHP does not in itself have a type of void, it is used in this document to refer to an unset value. It's very important for you to understand this difference since the the void parameter is heavily used by the exception handling system on which PostNuke API functions are based.

For example, pnModAPIFunc() takes parameters of a module name, type, and function, works out which actual module function to call; it then calls the module function and passes back the return value as its own return value. The problem with this is that if pnModAPIFunc() returned false for a failure to find the specified function then to the developer this would be indistinguishable from the function being found and itself returning false. void return values can be checked with the PHP isset() function, as shown below:

$articles = pnModAPIFunc('News', 'user', 'getarticles');
if (!isset($articles) && pnExceptionMajor() != PN_NO_EXCEPTION) {
// pnModAPIFunc() failed
return; // throw back exception
}
if ($articles == false)
// getarticles failed
} else {
// getarticles succeeded, data in $articles
}

Throughout the PostNuke API reference the return values of void and false are distinct. false is returned when an API call functioned correctly but returns a negative response. void is returned when an API call has internal problems and raises an exception. Note that this is a general rule, and there are a few exceptions out of necessity. These exceptions are noted in the reference documentation for the relevant function.

Table of Contents


pnBlockGetInfo - get block information
pnBlockLoad - load a block
pnBlockShow - set configuration variable
pnConfigGetVar - get configuration variable
pnConfigSetVar - set configuration variable
pnConfigDelVar - delete a configuration variable
pnDBGetConn - get database connection
pnDBGetTables - get database tables
pnDBInit - initialize MDPro database connection
pnExceptionFree - reset exception status
pnExceptionId - return current exception identifier
pnExceptionMajor - return current exception major number
pnExceptionSet - raise an exception
pnExceptionValue - return current exception value
pnGetBaseURI - get base URI for MDPro
pnGetBaseURL - obtain base URL for this site
pnGetStatusMsg - obtain status message
pnInit - initialize MDPro
pnModAPIFunc - execute a module API function
pnModAPILoad - load a module API
pnModAvailable - check if a module is available
pnModCallHooks - carry out hook operations for module
pnModDBInfoLoad - load database info for a module
pnModDelVar - delete a module variable
pnModFunc - execute a module function
pnModGetAdminMods - get list of administration modules
pnModGetIDFromName - get module id from name
pnModGetInfo - get module info
pnModGetName - get name of current top-level module
pnModGetUserMods - get list of user modules
pnModGetVar - get module variable
pnModLoad - load module
pnModRegisterHook - register a hook function
pnModSetVar - set module variable
pnModUnregisterHook - unregister a hook function
pnModURL - create module URL
pnRedirect - redirect to another page
pnSecAddSchema - add security schema
pnSecAuthAction - authorize attempted action
pnSessionDelVar - delete session variable
pnSessionGetVar - get session variable
pnSessionInit - initialize session
pnSessionSetup - setup session
pnSessionSetVar - set session variable
pnThemeLoad - load display theme
pnUserGetAll - get basic information on all users
pnUserGetLang - get current language
pnUserGetTheme - get current theme
pnUserGetVar - get user variable
pnUserGetVars - get all user variables
pnUserLoggedIn - check if user is logged in
pnUserLogIn - log user in
pnUserLogOut - log user out
pnUserSetVar - set user variable
pnUserValidateVar - validate user variable
pnVarCensor - remove banned words from variable
pnVarCleanFromInput - obtain form variable
pnVarPrepForDisplay - prepare variable for display
pnVarPrepForOS - prepare variable for operating system
pnVarPrepForStore - prepare variable for database storage
pnVarPrepHTMLDisplay - prepare variable for display, preserving some HTML tags
pnVarValidate - validate a variable

The following pages have a complete PostNuke API reference. Any functions that are not listed in this section are to be considered internal and should not be used by developers.

Examples

// Get information on block
$blockinfo = pnBlockGetInfo($bid);

Examples

// Get locale for this site
$locale = pnConfigGetVar('locale');