Modules
Modules V2
Module v2 features released as of version 1.319.0
Modules can be used to easily enable or disable certain features on existing applications with a toggle.
Connections to applications
Modules can be created for any application. V2 modules do not need to be added to the parent application, instead it is connected to the applications from the module application itself.
- Create of open a module type application in the development mode editor view
- Move to the ‘Modules’ tab
- Use the ‘Select application for module’ button to connect the module to needed application
The enable and disable checkbox here can be used to immediately enable the module.
By default, goerp does not limit the modules to groups like v1 modules did, but the following grouping can be used to create a custom behaviour similar to it. The custom group name field can be used to group modules to a custom radio group on the store and on the parent applications configure modules area.
Automatically merged data
Note that if the module contains translations or variables then these are automatically merged to the applications data when the module is enabled.
Modification type templates
With modules v2 the main file type for adjustments is the new type ‘modification’. By itself it does nothing. We need to configure it to alter something on a source page.
Multiple modifications can alter the same source (no defined limit).
- Create or edit a ‘modification’ type template in the module application.
- Open ‘Modules’ tab in the editor for the template.
You will see several options:
For template - Select the target template we want to alter
Module type - Select the module behaviour
- Replace all content - replaces all contents of the target
- Prepend all content - adds the module template contents before the target content
- Append all content - adds the module template contents after the target content
- Anchor - looks for the value in the ‘Module tag’ field and adds the content instead of it
- Replace by name - looks for the ‘Module tag’ html node and replaces its contents
- Prepend by name - looks for the ‘Module tag’ html node and adds content before its content
- Append by name - looks for the ‘Module tag’ html node and adds content after its content
- Prepend by ID - looks for the specific html node by its id and adds content before its content
Configure modules
Use the configure v2 modules button on the parent application ‘Modules’ tab or in the editor application structure view to enable and disable the modules.
In store
Note that v2 modules are not installed automatically from the store with the parent. Instead, the store will list all available modules from the store to the user, and the user can decide what to install.
However, the application type ‘bundle’ can be used to package the parent and modules into a single installation.
Examples
Adding new file dependencies to the source
Here we add an extra static css dependency to the original, adding a new line to the head of the document.
Parent index-page
<!DOCTYPE html>
<html>
<head>
<title>Demo modidied app</title>
<link rel="stylesheet" {{ .Tools.CSP }} href="{{ .Tools.StaticLink "dma-styles-css" }}">
</head>
<body>
<h1>Demo modified application</h1>
{{ $products := .Tools.Func "dma-fetch-products-func" }}
<div>
{{ range $products.Array }}
<div class="block">
<p>{{ .Get "productID" }}</p>
{{/* anchor */}}
</div>
{{ end }}
</div>
</body>
</html>
Modification template in module
For-template: index-page Module type: Append by name Module tag: head
<link rel="stylesheet" {{ .Tools.CSP }} href="{{ .Tools.StaticLink "dam3-styles-css" }}">
Replacing a custom anchor in the source
Here we use the anchor to just replace it in the source. Note that the anchor can be any value in the source.
Parent index-page
<!DOCTYPE html>
<html>
<head>
<title>Demo modidied app</title>
<link rel="stylesheet" {{ .Tools.CSP }} href="{{ .Tools.StaticLink "dma-styles-css" }}">
</head>
<body>
<h1>Demo modified application</h1>
{{ $products := .Tools.Func "dma-fetch-products-func" }}
<div>
{{ range $products.Array }}
<div class="block">
<p>{{ .Get "productID" }}</p>
{{/* anchor */}}
</div>
{{ end }}
</div>
</body>
</html>
Modification template in module
For-template: index-page Module type: Anchor Module tag: {{/* anchor */}}
<p>{{ .Get "code" }}</p>