Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Json field
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Description == Like a [[Compound field]], this field is designed to have a number of subfields which are all stored and displayed under the same parent field. However, unlike the Compound field, instead of storing each one in its own field or table, we store all the subfields in a single database field as a JSON string. === Installation === This module requires the <tt>HTML::Entities</tt> and <tt>JSON::Parse</tt> Perl libraries installed. Also requires <tt>jquery</tt> ingredient to be enabled in your [[EPrints_Glossary#Flavour|flavour's]] inc file. If you want to use the <tt>richtext</tt> sub-field type a [https://www.tiny.cloud/docs/tinymce/6/cloud-quick-start/ TinyMCE script] to be included either in a <tt><script></tt> tag in the archive's template or downloaded into the archive's <tt>cfg/static/javascript/auto/</tt> directory. === Usage === The field works by providing a <tt>json_config</tt>. parameter, for example: { name => "fieldname", type => "json", json_config => [ { name => "subfield1", type => "text" }, { name => "subfield2", type => "number" }, { name => "subfield3", type => "richtext" }, { name => "subfield4", type => "namedset", set_name => "example_set" } ], } === Compatible Sub-field Types === For the sub-fields the following sub-field types are currently compatible. These should not be conflated with EPrints MetaField types, of which some are emulated by the types below but are configured differently: * '''<tt>text</tt>''' - A single line text, (i.e. HTML <tt><input type="text"></tt>) * '''<tt>number</tt>''' - A numerical text field, (i.e. HTML <tt><input type="number"></tt>) * '''<tt>longtext</tt>''' - a multi-line text field (i.e. HTML <tt><textarea></tt>) * '''<tt>boolean</tt>''' - a checkbox field (i.e. HTML <tt><input type="checkbox"></tt>) * '''<tt>richtext</tt>''' - a multi-line text field with a WYSIWYG editor * '''<tt>namedset'''</tt> - a set of options (i.e. HTML <tt><select></tt> These all render as their comparative EPrints MetaFields would, however are rendered by JavaScript instead of the standard EPrints form renderer. The corresponding phrases for each subfield are in the format: * <code>eprint_fieldname_${fieldname}_${subfieldname}</code> * <code>eprint_fieldhelp_${fieldname}_${subfieldname}</code> === Table View === The JSON field can also be used to render a table, with a fixed number of rows. In this scenario, the JSON string stored is a JSON array. Use <tt>render_table</tt> to turn on the table mode, and <tt>table_row_count</tt> to specify the number of rows. In some tables, you may want to skip certain subfields - e.g. the third row doesn't have subfield 3. If the value of the subfield is <tt>__json_field_control__skip</tt>, the subfield will not render. If using resizeable richtext in your tables, you can use the reset button to put the fields/table columns back to their default size. If you set <tt>table_allow_hide_rows</tt> to be true, you get a select to select which rows you want to appear and which not. <tt>table_show_hide_rows</tt> default is <tt>true</tt>. This will show the selector. Allows you to hide on some views, e.g. allowing certain workflows to determine rows shown, and certain to edit values If you set <tt>table_hide_table</tt> to be <tt>true</tt>, the table is hidden, e.g. allowing certain workflows to determine rows shown, and certain to edit values If you set <tt>table_hide_rows_render_js</tt>, you can provide custom JavaScript to render the hide rows selector and how the json is updated. === List View === The JSON field can also be used to display the fields in multiple columns, instead of the standard one-after-the-other. This is helpful in scenarios where you have lots of small fields, e.g. a series of boolean checkboxes. Use <tt>display_as_list</tt> to turn on the list mode, and `display_as_list_cols` to specify the number of columns you want. === Lookup === You can provide an <tt>input_lookup_url</tt> as per standard MetaFields. When added, each subfield will have lookup capabilities. It will send the following as parameters to the <tt>input_lookup_url</tt> * <tt>q</tt> - the query * <tt>field</tt> - the json field name * <tt>json_field</tt> - the subfield name, per the <tt>json_config</tt> A basic CGI script that accepts these parameters and uses them to lookup on a particular subfield is provided.
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)