Difference between revisions of "EPScript/Examples"

From EPrints Documentation
Jump to: navigation, search
m (Reverted edit of JvgZ7x, changed back to last version by WikiSysop)
(Added formats template)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{formats}}
 +
 
{{EPScript}}
 
{{EPScript}}
  
 
= Examples =
 
= Examples =
  
Pluralising the editors of a book:
+
== Pluralising the editors of a book ==
 +
<source lang="xml">
 +
<if test="type = 'book' and is_set(editors)">
 +
  <print expr="editors" />, (ed<if test="length(editors) gt 1">s</if>
 +
</if>
 +
</source>
 +
 
 +
== Rendering the URL of an EPrint ==
 +
<source lang="xml">
 +
<print expr="$config{base_url}" />/<print expr="eprintid" />/
 +
</source>
  
{{codesample|
+
== Testing a boolean field ==
<pre>
+
Boolean fields can be <tt>TRUE</tt>, <tt>FALSE</tt> or <tt>NULL</tt>. Just doing a <code>test="boolean_field"</code> isn't enough. Use this:
<if test="type = 'book' and is_set(editors)">
+
<source lang="xml">
  <print expr="editors" />, (ed<if test="length(editors) gt 1">s</if>
+
<if test="boolean_field = 'TRUE'">
</if>
+
  ...
</pre>
+
</if>
}}
+
</source>

Latest revision as of 02:27, 21 February 2022

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


XML Configuration: EPScript - Control Format (EPC) - Citation - Workflow - Phrase - Template - XPAGE (static pages)


EPScript

Examples

Pluralising the editors of a book

 <if test="type = 'book' and is_set(editors)">
   <print expr="editors" />, (ed<if test="length(editors) gt 1">s</if>
 </if>

Rendering the URL of an EPrint

 <print expr="$config{base_url}" />/<print expr="eprintid" />/

Testing a boolean field

Boolean fields can be TRUE, FALSE or NULL. Just doing a test="boolean_field" isn't enough. Use this:

 <if test="boolean_field = 'TRUE'">
   ...
 </if>