Skip to content

Commit

Permalink
[doc] document jmodule functions
Browse files Browse the repository at this point in the history
  • Loading branch information
phproberto committed Jun 14, 2018
1 parent eba392d commit 767d78b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/_data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
32 changes: 32 additions & 0 deletions docs/functions/jmodule_get_module.md
Original file line number Diff line number Diff line change
@@ -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 <a id="parameters"></a>

* `string` **$name** Name of the module (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs')
* `array` **$title** [optional] Title of the module.

### Returns <a id="returns"></a>

`\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 <a id="examples"></a>

```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 %}
```
28 changes: 28 additions & 0 deletions docs/functions/jmodule_get_modules.md
Original file line number Diff line number Diff line change
@@ -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 <a id="parameters"></a>

* `string` **$position** Name of the position

### Returns <a id="returns"></a>

`array` An array containing modules of that position. Empty array if no modules were found.

### Examples <a id="examples"></a>

```twig
{% raw %}
{# Retrieve modules available in a `sidebar` position #}
{% set modules = jmodule_get_modules('sidebar') %}
{% for module in modules %}
<pre>Found module: {{ module.name }} with title: {{ module.title }}</pre>
{% endfor %}
{% endraw %}
```
28 changes: 28 additions & 0 deletions docs/functions/jmodule_render_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## jmodule_render_module($module, $attribs = array())

Render a module object.

1. [Parameters](#parameters)
1. [Returns](#returns)
2. [Examples](#examples)

### Parameters <a id="parameters"></a>

* `object` **$module** Object containing module information
* `array` **$attribs** [optional] Array of attributes for the module (probably from the XML).

### Returns <a id="returns"></a>

`\string` Rendered module.

### Examples <a id="examples"></a>

```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 %}
```

0 comments on commit 767d78b

Please sign in to comment.