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

Create a new PageIncludeService


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.


Lutece integrates by default several PageIncludeServices:

Links Inserting CSS Style Sheets and Specific Javascripts for Installed Plugins
Metas Insert meta tag values ​​from those defined in the file
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 Plugins can add new PageIncludeServices by declaring them in their XML file as follows:

     <page-include-service-name>My Include Service</page-include-service-name> 


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}
         * /
         public void fillTemplate (Map <String, Object> rootModel, PageData data, int nMode, HttpServletRequest request)
               rootModel.put (MARK_MY_INCLUDE, "My include content");