Skip to end of metadata
Go to start of metadata

$html = get_storage_html(parameter array);

 get_storage_html returns a ready html dropdown including JavaScript to select external storage configured by the user in the LoxBerry widgets (network, usb, local). The selected storage can be submitted in your HTML form, or directly used in JavaScript.

It makes it easy for the user and the developer to select and integrate storage devices into the plugin UI.

LoxBerry Compatibility

This features is available starting with LoxBerry 1.2.1. Use that version as your minimum version in your plugin.cfg.

To simplify parameter readability and usage, the function needs to be called with an array of named parameters.

Using the parameters, you can adjust the behaviour and design of the HTML dropdown.

The function can be used multiple times on every page, but the formid parameter must be unique for every call.


Parameter list of get_storage_html (Perl and PHP)



Name of the HTML form element including the resulting path. This id is used as id and name of the element. The input field is hidden in the form, but updated on every user change.


Giving a path, this is the pre-defined path of the dropdown element. Read the path from your config file and insert it here.

Omitting this parameter will set an empty path.



undef - The user is not allowed to add an additional subfolder to the selected storage.

1 - Behind the selected storage, the user can enter an own subfolder tree. But keep in mind that the plugin code has to care about the existance and creation of that folder.



If this parameter is omitted (default), all storage points are shown.

To only show writeable storage points, set readwriteonly => 1.

show_browsexundefDisplays an eye symbol right to the select box to open the current path in LoxBerry's File Manager. The eye symbol is disabled if the base path is outside of /opt/loxberry, as this is not allowed in LoxBerry's File Manager. (available from LoxBerry

This is the string label in front of the dropdown. Usually, set the label to a string from your plugin language phrases.

Without this parameter, the system default string "Storage path" (language specific) will be used.

data_minixundefThis flag corresponds to the jQuery Mobile flag data-mini="true". The controls are displayed in the data-mini="true" behaviour if set to 1.
Types of storage to show
type_allx1 oder 0

Using type_all => 1 (or omitting this parameter), all of the folloing storage types are shown. If you set at least one other type to 1, type_all is disabled.


USB storage devices are selectable.


Network shares are selectable.


The local plugin data directory ($lbpdatadir) is selectable.


The user can alternatively enter an own path.

Take care: If you want to prevent a custom path by type_custom = 0, and the sent currentpath value is not present in the available types, type_custom automatically enables as fallback. This prevents from loosing the configured path if a storage device (e.g. usb stick) is temporarily not available.


Return value

The function returns a string with html, that can be directly echoed to the output. In the case that anything fails, it returns nothing.

Usage with html form processing

Echo the generated html inside <form></form> tags. On submission, the formid name contains the full path (including folders) of the user selection. The path is the absolute path on LoxBerry.

A trailing / is always removed, also if you deliver it with currentpath.

Usage with JavaScript

the current, combined path can be accessed everytime, and every change can be monitored:

Change event
// This example assumes that get_storage_html was called with formid => 'mypath'

// Read current storage path
console.log("Current path is", $("#mypath").val());

// Monitor user changes to the path with the 'change' event
$("#mypath").change(function() {
	console.log("Path changed to", $("#mypath").val());


require_once "loxberry_storage.php";

# Define the parameter array
$params = array(
	"formid" => "mystorage",
	"currentpath" => $lbpdatadir,
	"readwriteonly" => 1,
	"label" => "Please enter the destination",

# This uses the id 'mystorage', sends the plugin datadir as currently configured directory, and only returns writable storages.
echo get_storage_html($params);

# Show only USB and network storage, allow custom path but no custom folder
$params = array(
	"formid" => "mystorage",
	"type_usb" => 1, 
	"type_net" => 1,
	"type_custom" => 1,	
echo get_storage_html($params);

  • No labels