Difference between revisions of "Url field"

From EPrints Documentation
Jump to: navigation, search
(Added ToC. Added API and Examples sections. Reorganised/completed other sections.)
Line 1: Line 1:
 
{{fieldtypes}}
 
{{fieldtypes}}
__NOTOC__
 
== Inheritance ==
 
  
* [[Metadata]]
 
** [[Text field]]
 
*** [[Url field]]
 
  
 
== Description ==
 
== Description ==
 +
This field works just like a [[Id field]] except that:
 +
* It gives a validation error if it does not appear to be a valid URL.
 +
* When rendered it is rendered as a link to the URL (unless the <code>render_dont_link</code> property is set).
 +
Also, as URLs are liable to be more that 256 characters this field is stored as a <code>LONGTEXT</code> field in the database.
  
This field works just like a text field except that
+
== Inheritance ==
* it gives a validation error if it does not appear to be a valid URL
+
* [[Metadata]]
* when rendered it is rendered as a link to the URL (unless the render_dont_link property is set).
+
** [[Text field]]
 +
*** [[Id field]]
 +
**** [[Url field]]
  
 
== Properties ==
 
== Properties ==
 +
As for [[Id fields]].
 +
 +
== Required Phrases ==
 +
No additional phrases beyond those required for [[Id field]]s
  
No extra properties.
+
== Database ==
 +
Url fields are stored in the database as
 +
fieldname LONGTEXT
  
== Required Phrases ==
+
== API ==
 +
See [[API:EPrints/MetaField/Url|API page]].
  
none.
+
== Examples ==
 +
Most basic example.
 +
  {
 +
    name => 'url',
 +
    type => 'url',
 +
  }
 +
Use a bespoke render function to truncate the URL at the end if it is too long.
 +
{
 +
    name => 'official_url',
 +
    type => 'url',
 +
    render_value => 'EPrints::Extras::render_url_truncate_end',
 +
}
 +
Use Url field as a sub-field in a multiple [[Compound field]].  Limiting the width of its input field.
 +
{
 +
    name => 'related_url',
 +
    type => 'compound',
 +
    multiple => 1,
 +
    render_value => 'EPrints::Extras::render_related_url',
 +
    fields => [
 +
        {
 +
            sub_name => 'url',
 +
            type => 'url',
 +
            input_cols => 40,
 +
        },
 +
        {
 +
            sub_name => 'type',
 +
            type => 'set',
 +
            options => [qw(
 +
                pub
 +
                author
 +
                org
 +
            )],
 +
        }
 +
    ],
 +
    input_boxes => 1,
 +
    input_ordered => 0,
 +
}

Revision as of 08:29, 9 April 2023

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


Metadata Fields: Arclanguage - Base64 - Bigint - Boolean - Compound - Counter - Dataobjref - Date - Decimal - Email - Fields - Float - Id - Idci - Image - Int - Itemref - Keywords - Langid - Longtext - Longtext_counter - Multilang - Multipart - Name - Namedset - Pagerange - Recaptcha - Recaptcha3 - Relation - Search - Secret - Set - Storable - Subject - Subobject - Text - Time - Timestamp - Url - Uuid


Description

This field works just like a Id field except that:

  • It gives a validation error if it does not appear to be a valid URL.
  • When rendered it is rendered as a link to the URL (unless the render_dont_link property is set).

Also, as URLs are liable to be more that 256 characters this field is stored as a LONGTEXT field in the database.

Inheritance

Properties

As for Id fields.

Required Phrases

No additional phrases beyond those required for Id fields

Database

Url fields are stored in the database as

fieldname LONGTEXT

API

See API page.

Examples

Most basic example.

 { 
    name => 'url', 
    type => 'url',
 }

Use a bespoke render function to truncate the URL at the end if it is too long.

{
    name => 'official_url',
    type => 'url',
    render_value => 'EPrints::Extras::render_url_truncate_end',
}

Use Url field as a sub-field in a multiple Compound field. Limiting the width of its input field.

{
    name => 'related_url',
    type => 'compound',
    multiple => 1,
    render_value => 'EPrints::Extras::render_related_url',
    fields => [
        {
            sub_name => 'url',
            type => 'url',
            input_cols => 40,
        },
        {
            sub_name => 'type',
            type => 'set',
            options => [qw(
                pub
                author
                org
            )],
        }
    ],
    input_boxes => 1,
    input_ordered => 0,
}