diff --git a/docs/_data/sidebar.yml b/docs/_data/sidebar.yml index b1d77b7..04a09ce 100644 --- a/docs/_data/sidebar.yml +++ b/docs/_data/sidebar.yml @@ -38,6 +38,12 @@ url: /functions/jlayout_debug - title: jlayout_render() url: /functions/jlayout_render + - title: jmodule_get_module() + url: /functions/jmodule_get_module + - title: jmodule_get_modules() + url: /functions/jmodule_get_modules + - title: jmodule_render_module() + url: /functions/jmodule_render_module - title: jposition() url: /functions/jposition - title: jprofiler() diff --git a/docs/functions/jmodule_get_module.md b/docs/functions/jmodule_get_module.md new file mode 100644 index 0000000..956aef7 --- /dev/null +++ b/docs/functions/jmodule_get_module.md @@ -0,0 +1,32 @@ +## jmodule_get_module($name, $title = null) + +Get a module published on the current page by its name or folder. + +1. [Parameters](#parameters) +1. [Returns](#returns) +2. [Examples](#examples) + +### Parameters + +* `string` **$name** Name of the module (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs') +* `array` **$title** [optional] Title of the module. + +### Returns + +`\stdClass|null` - The first module found that matches the name if found. Empty object if module not found and name starts with `mod_`. Null otherwise. + +### Examples + +```twig +{% raw %} +{# Retrieve a `mod_menu` module #} +{% set module = jmodule_get_module('mod_menu') %} + +{# Retrieve a `mod_menu` module by its name (name is the module element removing the mod_ part). #} +{% set module = jmodule_get_module('menu') %} + +{# Retrieve a `mod_menu` module with a specific title. #} +{% set module = jmodule_get_module('mod_menu', 'Main Menu') %} + +{% endraw %} +``` diff --git a/docs/functions/jmodule_get_modules.md b/docs/functions/jmodule_get_modules.md new file mode 100644 index 0000000..05c948a --- /dev/null +++ b/docs/functions/jmodule_get_modules.md @@ -0,0 +1,28 @@ +## jmodule_get_modules($position) + +Gets modules assigned to a specific position. + +1. [Parameters](#parameters) +1. [Returns](#returns) +2. [Examples](#examples) + +### Parameters + +* `string` **$position** Name of the position + +### Returns + +`array` An array containing modules of that position. Empty array if no modules were found. + +### Examples + +```twig +{% raw %} +{# Retrieve modules available in a `sidebar` position #} +{% set modules = jmodule_get_modules('sidebar') %} +{% for module in modules %} +
Found module: {{ module.name }} with title: {{ module.title }}
+{% endfor %} + +{% endraw %} +``` diff --git a/docs/functions/jmodule_render_module.md b/docs/functions/jmodule_render_module.md new file mode 100644 index 0000000..93595ed --- /dev/null +++ b/docs/functions/jmodule_render_module.md @@ -0,0 +1,28 @@ +## jmodule_render_module($module, $attribs = array()) + +Render a module object. + +1. [Parameters](#parameters) +1. [Returns](#returns) +2. [Examples](#examples) + +### Parameters + +* `object` **$module** Object containing module information +* `array` **$attribs** [optional] Array of attributes for the module (probably from the XML). + +### Returns + +`\string` Rendered module. + +### Examples + +```twig +{% raw %} +{# Retrieve and display all the modules in a sidebar position #} +{% for module in jmodule_get_modules('sidebar') %} + {{ jmodule_render_module(module) }} +{% endfor %} + +{% endraw %} +```