DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:data [2016-04-04 05:17] – [Download and Installationff] 111.193.48.226plugin:data [2024-02-01 23:50] (current) – version upped andi
Line 1: Line 1:
-====== Structured Data Plugin ======+====== data Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 6: Line 6:
 email      : andi@splitbrain.org email      : andi@splitbrain.org
 type       : syntax, action, helper type       : syntax, action, helper
-lastupdate : 2016-03-11 +lastupdate : 2024-01-30 
-compatible : Detritus, Hrun, Ponder Stibbons, Binky, Weatherwax, Adora Belle+compatible : Hogfather, Greebo, Frusterick Manners, Elenor Of Tsort, Detritus, Hrun, Ponder Stibbons, Binky, Weatherwax, Adora Belle, Igor
 depends    : sqlite depends    : sqlite
 conflicts  : fckg  #please create an issue report as well! conflicts  : fckg  #please create an issue report as well!
Line 20: Line 20:
  
 This plugin allows you to add structured data to any DokuWiki page. Think about this data as additional named attributes. Those attributes can then be queried and aggregated. The plugin is similar to what was done here for the [[repository|repository plugin]] but its internals are very different to it. This plugin allows you to add structured data to any DokuWiki page. Think about this data as additional named attributes. Those attributes can then be queried and aggregated. The plugin is similar to what was done here for the [[repository|repository plugin]] but its internals are very different to it.
 +
 +:!: You might want to consider using the spiritual successor to this plugin: [[plugin:struct|struct Plugin]]
  
 ===== Download and Installation ===== ===== Download and Installation =====
  
-Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
 ==== Changes ==== ==== Changes ====
Line 148: Line 150:
 For filtering, multiple comparators are possible: For filtering, multiple comparators are possible:
  
-^ Comparator       ^ Meaning ^ +^ Comparator        ^ Meaning                                                                                                                                            
-| ''=''            | Exact match | +| ''=''             | Exact match                                                                                                                                        
-| ''!='' or ''<>'' | Does not exactly match | +| ''!='' or ''<>''  | Does not exactly match                                                                                                                             
-| ''<''            | Less than | +| ''<''             | Less than                                                                                                                                          
-| ''%%<=%%''       | Less or equal than +| ''%%<=%%''        | Less than or equal to                                                                                                                              
-| ''>''            | Greater than | +| ''>''             | Greater than                                                                                                                                       
-| ''%%>=%%''       | Greater or equal than +| ''%%>=%%''        | Greater than or equal to                                                                                                                           
-| ''~''            | Wildcard match. Use a ''*'' as wildcard. Like ''Apple*'' to match ''Apple Pie'' and ''Apple Computer''; e.g. ''dessert~ *Pie''. Case insensitive.| +| ''~''             | Wildcard match. Use a ''*'' as wildcard. Like ''Apple*'' to match ''Apple Pie'' and ''Apple Computer''; e.g. ''dessert~ *Pie''. Case insensitive.  
-| ''*~''           | Wildcard match. Look for matches containing search term; e.g. ''dessert*~ Pi'' match ''Apple Pie''+| ''*~''            | Wildcard match. Look for matches containing search term; e.g. ''dessert*~ Pi'' match ''Apple Pie''                                                 
-| ''!~''           | Negative Wildcard match. Select everything that does not match the expression. | +| ''!~''            | Negative Wildcard match. Select everything that does not match the expression.                                                                     
-| ''~~''           | Looks if contained in given comma separated list; e.g. ''dessert ~~ diner,dessert''|+| ''~~''            | Looks if contained in given comma separated list; e.g. ''dessert ~~ diner,dessert''                                                                |
  
 You may use the special variables in a filter to make it match against current logged in user or current date  e.g. ''filter: username=%user%'' You may use the special variables in a filter to make it match against current logged in user or current date  e.g. ''filter: username=%user%''
  
-^Variable for filtervalue ^ Meaning ^ +^ Variable for filtervalue  ^ Meaning                                                                                                                                                                                                                
-| %user% | match against the currently logged in user | +| %user%                    | match against the currently logged in user                                                                                                                                                                             
-| %group% | match against the groups of the current user; use the ''~~'' comparator| +| %groups                 | match against the groups of the current user; use the ''~~'' comparator                                                                                                                                                
-| %now%  | compare with the current date              +| %now%                     | compare with the current date                                                                                                                                                                                          
-| %lang% | Language code of your default wiki language. e.g. ''en''+| %lang%                    | Language code of your default wiki language. e.g. ''en''                                                                                                                                                               
-| %trans%  | Language code of the localisation of the current page.\\ Requires the [[Translation]] Plugin. For page link ''de:test:page'', it is replaced by\\ ''de''. Fallback to default lang. Empty without Translation Plugin.  |+| %trans%                   | Language code of the localisation of the current page.\\ Requires the [[Translation]] Plugin. For page link ''de:test:page'', it is replaced by\\ ''de''. Fallback to default lang. Empty without Translation Plugin.  |
  
  
Line 305: Line 307:
 </code> </code>
  
-And in Admin -> Page Aliases (''do=admin&page=data_aliases'') define:+And in Admin -> Data Plugin: Field Aliases (''do=admin&page=data_aliases'') define:
  
 ^ Type Alias ^ Type ^ Data Prefix ^ Data Postfix ^ Valid values | ^ Type Alias ^ Type ^ Data Prefix ^ Data Postfix ^ Valid values |
Line 345: Line 347:
  
 === vCard type alias with vCard Plugin === === vCard type alias with vCard Plugin ===
-Setup for the [[plugin:vCard]] plugin is similar to iCal+ 
 +Setup for the [[plugin:vCard]] plugin is similar to iCal.
  
  
Line 400: Line 403:
 ===== Translation Support ===== ===== Translation Support =====
  
-If you use the [[translation]] plugin, you might want to use the same data entries in different languages. The plugin allows for translated field names - values will not be translated. If you only want to use English field names while having them displayed in your language, you can also follow these instructions.+If you use the [[translation]] plugin, you might want to use the same data entries in different languages. The plugin allows for translated field names -- values will not be translated. If you only want to use English field names while having them displayed in your language, you can also follow these instructions.
  
 To create fieldname translations, create a file in ''conf/lang/<langcode>/data-plugin.php''. The file needs to contain a PHP array named ''$lang'' with the fieldname in the array key and the translation in the value: To create fieldname translations, create a file in ''conf/lang/<langcode>/data-plugin.php''. The file needs to contain a PHP array named ''$lang'' with the fieldname in the array key and the translation in the value:
Line 412: Line 415:
 Fieldnames are to be given without their type. So it's ''deadline'' not ''deadline_dt''. Fieldnames are to be given without their type. So it's ''deadline'' not ''deadline_dt''.
  
-After creating or modifiying data-plugin.php file, please update wiki configuration to refresh cache ''start?do=admin&page=config'', otherwise modifications are not taken into account.+After creating or modifiying data-plugin.php file, please update wiki configuration to refresh cache ''%%start?do=admin&page=config%%'', otherwise modifications are not taken into account.
  
 ===== Missing Features ===== ===== Missing Features =====
Line 418: Line 421:
   * more control options:   * more control options:
     * attribute list (similar to tag cloud but as a simple list)     * attribute list (similar to tag cloud but as a simple list)
-    * search field -- See [[plugin:datasearchform]]+    * search field -- see [[plugin:datasearchform]] plugin
   * **better documentation, examples**   * **better documentation, examples**
     * Please provide suggestions for which pieces need more attention or where you do not understand stuff. Thanks.     * Please provide suggestions for which pieces need more attention or where you do not understand stuff. Thanks.
Line 436: Line 439:
   * This plugin may be seen in action on this wiki in the [[:dokuinstall|DokuWiki Installations]] namespace.    * This plugin may be seen in action on this wiki in the [[:dokuinstall|DokuWiki Installations]] namespace. 
     * Look for the ''datatable'' in the source of [[:dokuinstall|DokuWiki Installations]]     * Look for the ''datatable'' in the source of [[:dokuinstall|DokuWiki Installations]]
-    *  and for a ''dataentry'' in some of the [[dokuinstall:southeastern|individual installation pages]].+    * and for a ''dataentry'' in some of the [[dokuinstall:southeastern|individual installation pages]].
   * Very interesting and organized wiki setup: [[http://www.ickewiki.de/ickewiki|ICKEwiki]] by [[http://www.cosmocode.de/en/wiki/ickewiki|Cosmocode]] integrates the Data Plugin with some other plugins such as [[Bureaucracy]] to a complete enterprise wiki tool. Follow links to the (German) Demo, which let you access the wiki as employee.    * Very interesting and organized wiki setup: [[http://www.ickewiki.de/ickewiki|ICKEwiki]] by [[http://www.cosmocode.de/en/wiki/ickewiki|Cosmocode]] integrates the Data Plugin with some other plugins such as [[Bureaucracy]] to a complete enterprise wiki tool. Follow links to the (German) Demo, which let you access the wiki as employee. 
   * [[plugin:data:list_of_employees|DokuWiki usecase: list of employees]] -- How to use Data Plugin with [[Bureaucracy]] Plugin and [[Wrap]] Plugin. A manual by [[user>lolmaus]].   * [[plugin:data:list_of_employees|DokuWiki usecase: list of employees]] -- How to use Data Plugin with [[Bureaucracy]] Plugin and [[Wrap]] Plugin. A manual by [[user>lolmaus]].
Line 460: Line 463:
 The [[plugin:strata|Strata Plugin]] is in the big lines equivalent to Data plugin. However, it has more sophisticated query syntax, less and simpler 'aliastypes' system and additional features like graph or output based at an predefined template. So for handling of more complicated data the Strata Plugin has more opportunities. The [[plugin:strata|Strata Plugin]] is in the big lines equivalent to Data plugin. However, it has more sophisticated query syntax, less and simpler 'aliastypes' system and additional features like graph or output based at an predefined template. So for handling of more complicated data the Strata Plugin has more opportunities.
  
-==== How do you filter empty fields/values ? ====+==== How do you filter empty fields/values? ====
  
-Suppose some entries contain empty fields and you want to display such entries : how do you write the filter in the query to output these ? +Suppose some entries contain empty fields and you want to display such entries: how do you write the filter in the query to output these?
  
-e.g +e.g.
  
 <code> <code>
Line 476: Line 479:
 </code> </code>
  
-and if the query is :+and if the query is:
 <code> <code>
 ---- datatable ---- ---- datatable ----
Line 485: Line 488:
 </code> </code>
 the output does not show the above record the output does not show the above record
 +
 +^The solution is to change the filter to a value that will always be populated. ^
 +|<code>---- datatable ----
 +cols    : %pageid%
 +headers : Details
 +filter  : %class% = projects
 +----</code>|
 +|  --- [[user>SFITCS|SFITCS]] //2016-10-15 04:58//|
 +
 +==== Why don't my variables/placeholders work when I create a table in a namespace template? ====
 +
 +DokuWiki calls [[phpfn>strftime]] on ''_template.txt'' when creating a new page. This replaces some combinations of %[a-z] (for example, %title% will become [TAB]itle%). When using placeholders in ''_template.txt'' you should use double percent signs (<nowiki>%%title%%</nowiki>). Strftime will treat those as literal percent characters.
 +
 ==== Other Questions ==== ==== Other Questions ====
  
-If you still have questions, search the forum and if it hasn't been asked before ask your question there. Please leave bugreports on Githubs issuetracker.+If you still have questions, search the forum and if it hasn't been asked before ask your question there. Please leave bug reports on Github's issue tracker. 
 + 
 +---- 
 + 
 +===== Customisations ===== 
 + 
 +**Important!** These are //hacks// -- there is no guarantee they'll always work, and they will **not** survive updates.  
 + 
 +If it breaks you get to keep the pieces. :-) 
 + 
 +==== Customise the Date Format ==== 
 + 
 +**NOTE:** The configuration setting for the PHP strftime function in ''/conf/dokuwiki.php'' also need to be changed (can also be changed via **Admin->Configuration**) <code>$conf['dformat'    = '%d/%m/%Y %H:%M';</code> 
 + 
 +To change the default date format from ''yy-mm-dd'' to ''dd-mm-yy'' (e.g. for Australia) 
 + 
 +Change this: 
 +<code php plugins/data/helper.php> 
 +    /** 
 +     * Replace placeholders in sql 
 +     */ 
 +    function _replacePlaceholdersInSQL(&$data) { 
 +        global $USERINFO; 
 +        // allow current user name in filter: 
 +        $data['sql'] = str_replace('%user%', $_SERVER['REMOTE_USER'], $data['sql']); 
 +        $data['sql'] = str_replace('%groups%', implode("','", (array) $USERINFO['grps']), $data['sql']$ 
 +        // allow current date in filter: 
 +        $data['sql'] = str_replace('%now%', dformat(null, '%Y-%m-%d'), $data['sql']); 
 + 
 +        // language filter 
 +        $data['sql'] = $this->makeTranslationReplacement($data['sql']); 
 +    } 
 +</code> 
 + 
 +to this: 
 +<code php plugins/data/helper.php> 
 +    /** 
 +     * Replace placeholders in sql 
 +     */ 
 +    function _replacePlaceholdersInSQL(&$data) { 
 +        global $USERINFO; 
 +        // allow current user name in filter: 
 +        $data['sql'] = str_replace('%user%', $_SERVER['REMOTE_USER'], $data['sql']); 
 +        $data['sql'] = str_replace('%groups%', implode("','", (array) $USERINFO['grps']), $data['sql']$ 
 +        // allow current date in filter: 
 +        $data['sql'] = str_replace('%now%', dformat(null, '%d-%m-%Y'), $data['sql']); 
 + 
 +        // language filter 
 +        $data['sql'] = $this->makeTranslationReplacement($data['sql']); 
 +    } 
 +</code> 
 + 
 +and change this: 
 +<code php plugins/data/helper.php> 
 +switch($type) { 
 +            case 'dt': 
 +                if(preg_match('/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/', $value, $m)) { 
 +                    return sprintf('%d-%02d-%02d', $m[1], $m[2], $m[3]); 
 +                } 
 +</code> 
 + 
 +to this: 
 +<code php plugins/data/helper.php> 
 +switch($type) { 
 +            case 'dt': 
 +                if(preg_match('/^(\d\d?)-(\d\d?)-(\d\d\d\d)$/', $value, $m)) { 
 +                    return sprintf('%02d-%02d-%d', $m[1], $m[2], $m[3]); 
 +                } 
 +</code> 
 + 
 +and change this: 
 +<code javascript plugins/data/script.js> 
 +/** 
 + * Init datepicker for all date fields 
 + */ 
 +jQuery(function () { 
 +    jQuery('.data_type_dt input').datepicker({ 
 +        dateFormat: "yy-mm-dd", 
 +        changeMonth: true, 
 +        changeYear: true 
 +    }); 
 +</code> 
 + 
 +to this: 
 +<code javascript plugins/data/script.js> 
 +/** 
 + * Init datepicker for all date fields 
 + */ 
 +jQuery(function () { 
 +    jQuery('.data_type_dt input').datepicker({ 
 +        dateFormat: "dd-mm-yy", 
 +        changeMonth: true, 
 +        changeYear: true 
 +    }); 
 +</code>  --- [[user>SFITCS]] //2016-11-26 01:24//
  
 ===== Bugs, Feature Requests and Patches ===== ===== Bugs, Feature Requests and Patches =====
  
-Please submit bugs and feature requests in the [[https://github.com/splitbrain/dokuwiki-plugin-data/issues|issue tracker on github]]. Patches should be sent unified diff format or as git patches against the devel branch. Or even better: fork the repository at github and send a merge request.+Please submit bugs and feature requests in the [[https://github.com/splitbrain/dokuwiki-plugin-data/issues|issue tracker on GitHub]]. Patches should be sent unified diff format or as git patches against the devel branch. Or even better: fork the repository at github and send a merge request. 
plugin/data.1459739870.txt.gz · Last modified: 2016-04-04 05:17 by 111.193.48.226

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki