Mar 8, 2018 11:36:35 AM seb leridon avatar   795

Create a new PageIncludeService


Definition

PageIncludeServices are services that allow you to include HTML code in the pages of the site through bookmarks placed in the main template of the portal ( page_frameset.html ). These services can introduce content but are rather intended insert technical code in non-accessible locations for portlets or the XPageApp. For example insert dynamically, in the part <head> HTML pages, links to CSS style sheets or to RSS files.

Declaration

Lutece integrates by default several PageIncludeServices:

NameDescription
Links Inserting CSS Style Sheets and Specific Javascripts for Installed Plugins
Metas Insert meta tag values ​​from those defined in the file webmaster.properties
Themes Dynamic management of CSS style sheet paths according to the theme associated with the page
Statistics Insert the HTML code specific to the audience measurement tool

The default services are declared in the file lutece.properties Plugins can add new PageIncludeServices by declaring them in their XML file as follows:

<page-include-service> 
     <page-include-service-name>My Include Service</page-include-service-name> 
     <page-include-service-class>fr.paris.lutece.myplugin.web.MyInclude</page-include-service-class> 
 </page-include-service>

Implementation

A PageIncludeService must implement the PageInclude interface.

Here is a very simple example of implementation:

public class MyInclude implements PageInclude
  {
         private static final String MARK_MY_INCLUDE = "my_include";

         / **
         * {@inheritDoc}
         * /
         @Override
         public void fillTemplate (Map <String, Object> rootModel, PageData data, int nMode, HttpServletRequest request)
         {
               rootModel.put (MARK_MY_INCLUDE, "My include content");
         }
 }