How to enable server side includes

From EPrints Documentation
Revision as of 13:55, 19 August 2020 by Libjlrs (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Warning This feature requires EPrints version 3.2.1 or later

You must have the Apache Server Side Includes (SSI) module installed and enabled.

This enables you to add includes to the content of static pages. If you want to add dynamic content to the template you should do this via a template part in cfg.d/dynamic_template.pl.

Configuration

Edit cfg/apache/[repoid].conf and add to the <Location> section AddOutputFilter and +Includes:

 <Location "/eprints">
   PerlSetVar EPrints_ArchiveID myrepo
   
   AddOutputFilter INCLUDES .html
   
   Options +ExecCGI +Includes
   Order allow,deny 
   Allow from all
 </Location>

Restart apache.

Example

<!--#include virtual="/cgi/mydynbit"-->

Issues calling cgi scripts with parameters (issue seen with v3.3.16 / Apache 2.4 / Ubuntu)

When trying to include a URL with parameters, the EPrints stack will see the URL parameters of the main page, not the included request e.g. if this include:

<!--#include virtual="/cgi/latest_tool?mode=test&mainonly=yes" -->

was used on the main index page, if the page was requested with no URL parameters, the latest_tool would not see the mode=test, or mainonly=yes parameters.

Solution

The cgi script needs to determine whether it is the main apache request, or a sub-request (e.g. the SSI).

The following line, placed near the top of the cgi script appears to resolve the issue.

local $session->{query} = CGI->new( $session->get_request ) if( !$session->get_request->is_initial_req );