Difference between revisions of "Url field"

From EPrints Documentation
Jump to: navigation, search
m
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{fieldtypes}}
 +
 +
 +
== 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.
 +
 +
== Inheritance ==
 
* [[Metadata]]
 
* [[Metadata]]
 
** [[Text field]]
 
** [[Text field]]
*** [[Url field]]
+
*** [[Id field]]
 +
**** [[Url field]]
  
== Description ==
+
== Additional Properties ==
 +
As for [[Id field#Additional Properties|Id fields]].
  
This field works just like a text field except that
+
== Required Phrases ==
* it gives a validation error if it does not appear to be a valid URL
+
No additional phrases beyond those required for [[Id field#Required Phrases|Id fields]].
* when rendered it is rendered as a link to the URL (unless the render_dont_link property is set).
 
 
 
== Properties ==
 
  
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,
 +
}

Latest revision as of 23:21, 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 - 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

Additional 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,
}