Difference between revisions of "Dynamic template.pl"

From EPrints Documentation
Jump to: navigation, search
(Added page about config file)
 
(Added actually file name in bold. Also discuss template_core as a supersedent.)
 
Line 2: Line 2:
 
{{cfgd}}
 
{{cfgd}}
  
This file contains the enabling (i.e. <code>$c->{dynamic_template}->{enable} = 1;</code>) and the option to define a function for the dynamic template.  This allow parts of the template (i.e. pins) to be defined on-the-fly.
+
'''dynamic_template.pl''' is superseded by [[template_core.pl]] but is linked into this through [[template_legacy.pl]], so can still be used if so wanted.
 +
 
 +
This file contains the enabling (i.e. <code>$c->{dynamic_template}->{enable} = 1;</code>) and the option to define a function for the dynamic template.  This allow parts of the template (i.e. pins) to be defined on-the-fly.
 
  $c->{dynamic_template}->{function} = sub {
 
  $c->{dynamic_template}->{function} = sub {
 
   my( $repository, $parts ) = @_;
 
   my( $repository, $parts ) = @_;

Latest revision as of 12:23, 27 January 2022

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


Back to cfg.d

dynamic_template.pl is superseded by template_core.pl but is linked into this through template_legacy.pl, so can still be used if so wanted.

This file contains the enabling (i.e. $c->{dynamic_template}->{enable} = 1;) and the option to define a function for the dynamic template. This allow parts of the template (i.e. pins) to be defined on-the-fly.

$c->{dynamic_template}->{function} = sub {
  my( $repository, $parts ) = @_;
  $parts->{mypin} = $repository->xml->create_text_node( "Hello, World!" );
};

The above example sets the pin mypin to the text string Hello, World!. This can then be included in the archive's template (e.g. cfg/lane/en/templates/default.xml) with the markup:

<epc:pin ref="mypin"/>

As well as the dynamic template function there is configuration to define the order that the main options in EPrints' key_tools:

$c->{plugins}->{"Screen::Login"}->{appears}->{key_tools} = 100;
$c->{plugins}->{"Screen::Register"}->{actions}->{register}->{appears}->{key_tools} = 150;
$c->{plugins}->{"Screen::Logout"}->{appears}->{key_tools} = 10000;
$c->{plugins}->{"Screen::Admin::Config::Edit::XPage"}->{actions}->{edit}->{appears}->{key_tools} = 1250;
$c->{plugins}->{"Screen::Admin::Phrases"}->{actions}->{edit}->{appears}->{key_tools} = 1350;
$c->{plugins}->{"Screen::OtherTools"}->{appears}->{key_tools} = 20000;