If you want to place (content) elements on your webpage via drag&drop, you have to define a content type for the elements, provide a formatter and configure a resource type. What if your element has no real content, when it just renders a search, login or other form, or something else without using content specific values? This element should be a dynamic function! Dynamic functions add functionality to your webpage that does not rely on specific content values.
The dynamic function content type
The dynamic function content's elements are a title, a description, a JSP to render the function, plus some optional configuration elements.
The most interesting thing about a dynamic function is the JSP. It is used to render the dynamic function. So, it's comparable to a formatter for the other content types. Loosely spoken, each dynamic function content holds its own formatter. Via the Matching containers (Container types) you can choose in which containers the dynamic function can be placed - similar to the option in formatter configurations. The element settings can be read by the function provider to alter it's behavior. Just like they are read in formatters for other content types.
Besides element settings, also parameters can be defined in a dynamic function. These parameters are passed as request parameters to the function provider each time it is called. You can also pass parameters dynamically as for each other page, e.g., when rendering a form's result page. These parameters are not defined in the dynamic function.
Title and description should be chosen in a meaningful way. They are displayed in the add wizard of the page editor to identify the function.
Pros and cons of dynamic functions
Dynamic functions provide an easy way to add functionality via drag & drop without adding a new content type. Thus on the pro side:
- No resource type configuration required
- Detail pages possible
But, dynamic functions also have their cons:
- In the add wizard of the page editor either all dynamic functions or none are shown
- No specific icon is configurable for a dynamic function
OpenCms 11 introduced a new function type (
function_config) that superseeds the former type (
function). The intention is to get the content and all options closer to a formatter configuration.