Dev:Using Options

From Habari Project

Jump to: navigation, search

Options are site-specific values stored in the site's database.

Contents

Options

It is recommended that Options belonging to a Plugin have names prepended with the plugin's name. For example, the twitter plugin has a limit option, twitter__limit.

Get

Retrieve a stored Option.

$limit = Options::get( "twitter__limit" );

It is also possible to assign a default value using the optional second argument. In the following example, if no limit has been set, 1 will be returned.

$limit = Options::get( "twitter__limit", 1 );

Set

Store an Option.

Options::set( "twitter__limit", $limit );

Delete

Unset an Option from the database.

Options::delete( "twitter__limit" );

It is also possible to unset a number of Options if they are passed as an array.

Options::delete( array( "twitter__limit", "twitter__prepend" ) );

Clear Cache

Options Groups

Get

Set

Delete

Other Development Pages · Developer Introduction
Personal tools