--- a/src/source/howto-template.rst Thu Jun 28 12:05:42 2018 +0200
+++ b/src/source/howto-template.rst Tue Aug 14 18:26:02 2018 +0200
@@ -1,6 +1,63 @@
.. _templatehowto:
-How to create a new template?
-=============================
+How to define or change a template for a specific skin?
+=======================================================
+
+Override the default template for a renderer
+--------------------------------------------
+
+If you want to modify the template for a particular rendering mode, you can use the function :py:func:`override_template`
+
+.. code-block:: python
+
+ from pyams_template.template import override_template
+
+ from my_website.skin.public.layer import ICustomLayer
+ from pyams_default_theme.component.keynumber.portlet import KeyNumberPortletHorizontalRenderer
+
+
+ override_template(context=KeyNumberPortletHorizontalRenderer,
+ template="templates/keynumber-horizontal.pt",
+ layer=ICustomLayer
+ )
+
+
+This new template can be applied to a particular :ref:`Skin <skinhowto>` by specifying on which layer to use this renderer
+*(ex: layer=IMyWebsiteLayer)*
+
+
+
+Redefine the default template for a renderer
+--------------------------------------------
+You must redefine an adapter to add new variables or static resources for your new template,
+
+.. code-block:: python
+
+ # import interfaces
+ from my_website.skin.public.layer import ICustomLayer
+
+ from pyams_content.component.keynumber.portlet.interfaces import IKeyNumberPortletSettings
+ from pyams_portal.interfaces import IPortletRenderer, IPortalContext
+
+ # import packages
+ from my_website.skin.public import my_carousel_init ,my_carousel_animation
+
+ from pyams_default_theme.component.keynumber.portlet import KeyNumberPortletHorizontalRenderer
+ from pyams_template.template import template_config
+ from pyams_utils.adapter import adapter_config
+ from zope.interface import Interface
+
+
+ @adapter_config(context=(IPortalContext, IBaseLayer, Interface, IKeyNumberPortletSettings),
+ provides=IPortletRenderer)
+ @template_config(template='templates/keynumber-horizontal.pt', layer=ICustomLayer)
+ class MyCustomKeyNumberPortletHorizontalRenderer(KeyNumberPortletHorizontalRenderer):
+ """Key numbers portlet horizontal renderer"""
+
+ resources = (my_carousel_init, my_carousel_animation)
+
+
+The attribute :py:attr:`resources` is used to load in the template static resources. The application will automatically
+integrate resource content when the template is calling.