Content - ContentEntry API


Basics

The ContentEntry class allows you to store language file key/value pairs in the database. With it you can enable user-friendly access (along with inline editing) to language file editing.

To load ContentEntry values, use ContentEntry::load(). Typically this will be placed in your default controller’s __load() method.

By default, the write access to these features are completely disabled. You can enable it by updating the configuration file content.conf.ini as such:

contententry_api_enabled = true

API endpoint

Once enabled, authenticated users can connect to the /admin/contententry/update/ endpoint. You can use POST or GET method to update data by sending the following parameters:

key The key name to edit.
locale The locale of the entry. Defaults to current, but you should specify this.
value The value data to pass.
type The type of data passed. This can be ‘text’ (default), ‘richtext’, or ‘picture’

Here’s an example request:

http://example.com/admin/contententry/update/?key=my_lang_key&locale=en_US&value=My%20important%20text!&type=text

The ContentEntry API loads up the default admin __load controller method so any request must pass through the default admin authentication process.

Some important notes on data processing:

  • OFW will preprocess the data based on the type parameter. Data will NOT be processed if type is empty.
  • All HTML is encoded for text types
  • The following tags are supported for richtext types: <a><i><b><u><em><strong><br>
  • Picture types must send picture data in value as base64-encoded data

Admin panel

The plugin also includes an admin panel where users can update key/value pairs. Creating new entries however is only supported via the API for now.

http://example.com/admin/contententry/

As the API, this too is disabled by default and must be enabled in the configuration file.

Enabling and using

Though you can use the ContentEntry API directly, most often you will use it with the inline content editor features. To enable and use the inline content editing features, check out the documentation on this topic.

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |