devel:metadata
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devel:metadata [2009-11-24 00:54] – add 'date valid age' (rss only) to list of core elements ChrisS | devel:metadata [2023-02-28 07:43] (current) – Link to new dokuwiki repo saggi | ||
---|---|---|---|
Line 2: | Line 2: | ||
If the content stored in a wiki page is //data//, things like the time of last update, who updated it, the filesize etc. could all be regarded as // | If the content stored in a wiki page is //data//, things like the time of last update, who updated it, the filesize etc. could all be regarded as // | ||
+ | |||
+ | Metadata can also be used by plugins for different purposes, apart from storing obvious metadata for the page it can also be used to store data that can be used to determine whether a cache can be used or settings like if a certain feature of the plugin should be enabled on a page. | ||
===== Storage ===== | ===== Storage ===== | ||
- | DokuWiki does not store all metadata at central place (like a database or registry). Metadata can basically be the own datafile' | + | DokuWiki does not store all metadata at central place (like a database or registry). Metadata can basically be the own datafile' |
===== Metadata Renderer ===== | ===== Metadata Renderer ===== | ||
- | Info in the '' | + | Info in the '' |
- | + | ||
- | ==== Functions to Get and Set Metadata ===== | + | |
- | + | ||
- | There are two functions in '' | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
==== Data Structure ==== | ==== Data Structure ==== | ||
Line 29: | Line 17: | ||
Currently, the following metadata is saved by the core metadata renderer: | Currently, the following metadata is saved by the core metadata renderer: | ||
- | * ' | + | * ''title'' -- string, first heading |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * ''date'' -- array |
- | * ' | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * ''valid'' |
- | * ' | + | * ''age'' -- seconds, period in seconds before the page should be refreshed (used by ' |
- | * ' | + | * '' |
- | * ' | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
Additionally, | Additionally, | ||
- | * ' | + | * '' |
- | * 'ispartof' -- array, list of pages that include the current page: ID => boolean exists | + | * '' |
- | * 'haspart' -- array, list of included pages: ID => boolean exists ([[plugin:include]] plugin) | + | * '' |
- | * ' | + | * '' |
- | * ' | + | * '' |
+ | * ''type'' -- string, ' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
It's recommended to use keys from the [[http:// | It's recommended to use keys from the [[http:// | ||
+ | |||
+ | For plugin internal data it is recommended to store your keys under the '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | This data is stored in an associative array with two keys: ' | ||
==== Metadata Persistence ==== | ==== Metadata Persistence ==== | ||
Line 64: | Line 83: | ||
+ | ==== Running of metadata rendering ==== | ||
+ | The metadata rendering is only started by the '' | ||
+ | |||
+ | The metadata renderer creates also an short raw text abstract. The abstract is created from the rendered instruction by adding compact text without html to '' | ||
+ | <code php> | ||
+ | // capture only the first few sections. | ||
+ | // Is switched off as well by eg. section metarenderer | ||
+ | if ($this-> | ||
+ | if($linktitle) { | ||
+ | $this-> | ||
+ | } else { | ||
+ | $this-> | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The timing is thus not equal to xhtml renderer, but depends on render flags given to the '' | ||
==== Metadata and Plugins ==== | ==== Metadata and Plugins ==== | ||
- | In addition | + | There are two ways for plugins |
+ | |||
+ | * [[Syntax Plugins]] can create metadata for the rendered page with their '' | ||
+ | * [[Action Plugins]] can register for the [[.event: | ||
+ | |||
+ | Persistent metadata can also be set at any time using the '' | ||
+ | |||
+ | Metadata can be retrieved using the '' | ||
+ | |||
+ | Note that persistent metadata is never cleaned and always used as basis for the current metadata so when switching from persistent to non-persistent metadata in a plugin make sure you implement a cleanup routine which removes persistent metadata from your plugin whenever it exists. For this reason non-persistent metadata should also be preferred whenever possible. | ||
+ | |||
+ | If you want to make sure that your plugin' | ||
+ | |||
+ | As it is very difficult to cleanly update persistent metadata properties that are arrays from various places (in most cases you don't know which is old metadata that should be cleaned up and which is metadata from other plugins that should be kept - or not because the plugin was disabled) consider using keys that are unique to your plugin for this case and merge them manually into the current metadata using the [[.event: | ||
+ | |||
+ | ==== Functions to Get and Set Metadata ===== | ||
+ | |||
+ | There are two functions in '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==== Metadata and caching ==== | ||
+ | |||
+ | In general, metadata is rendered on demand when '' | ||
+ | |||
+ | When metadata is requested inside the cache handler the old metadata is returned, that way you can compare new data to the old stored metadata in order to decide whether to use the cache or not. In the xhtml cache handler you get the new metadata but as the xhtml cache depends on the metadata whenever you change the metadata the xhtml will be updated. | ||
+ | |||
+ | In versions prior to 2011, metadata was only rendered when the xhtml was rendered. Back then you got the old metadata in the xhtml cache handler, plugins that still rely on this need to be updated. | ||
+ | |||
+ | ===== Metadata index ===== | ||
+ | |||
+ | Since the 2011-05-25 (" | ||
+ | |||
+ | The data is updated right after the [[fulltextindex]] so it can be regenerated in the same way, when a plugin wants to force an update of the index of a certain page it can delete the '' | ||
+ | |||
+ | The indexer object (which can be obtained by using '' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | Example for getting the ids of all pages that link to a certain page: <code php> | ||
- | [[Syntax Plugins]] can create metadata | + | For more advanced queries (like getting all values stored for a certain metadata property) can be needed to access the index files directly using '' |
- | [[Action Plugins]] can register for the [[events_list# | + | The [[plugin:tag]] plugin uses the metadata index, in its helper part there are example of how the index can be queried, in its action part you can see how the index is written. |
devel/metadata.1259020465.txt.gz · Last modified: by ChrisS