PHPackages                             dd/evolutioncms-snippets-ddmenubuilder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. dd/evolutioncms-snippets-ddmenubuilder

ActiveModxevo-snippet[Templating &amp; Views](/categories/templating)

dd/evolutioncms-snippets-ddmenubuilder
======================================

Simple and flexible template-driven menu builder. Initially inspired by combination of the Wayfinder and Ditto advantages with significant code simplification.

2.2.0(3y ago)02[2 issues](https://github.com/DivanDesign/EvolutionCMS.snippets.ddMenuBuilder/issues)PHPPHP &gt;=5.6.0

Since Mar 7Pushed 1y ago2 watchersCompare

[ Source](https://github.com/DivanDesign/EvolutionCMS.snippets.ddMenuBuilder)[ Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddmenubuilder)[ Docs](https://code.divandesign.ru/modx/ddmenubuilder)[ RSS](/packages/dd-evolutioncms-snippets-ddmenubuilder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (5)Used By (0)

(MODX)EvolutionCMS.snippets.ddMenuBuilder
=========================================

[](#modxevolutioncmssnippetsddmenubuilder)

Simple and flexible template-driven menu builder. Initially inspired by combination of the Wayfinder and Ditto advantages with significant code simplification.

Requires
--------

[](#requires)

- PHP &gt;= 5.6
- [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) &gt;= 1.1
- [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.ru/modx/ddtools) &gt;= 0.59

Installation
------------

[](#installation)

### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)

[](#using-modxevolutioncmslibrariesddinstaller)

Just run the following PHP code in your sources or [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console):

```
//Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
	$modx->getConfig('base_path') .
	'assets/libs/ddInstaller/require.php'
);

//Install (MODX)EvolutionCMS.snippets.ddMenuBuilder
\DDInstaller::install([
	'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddMenuBuilder',
	'type' => 'snippet'
]);
```

- If `ddMenuBuilder` is not exist on your site, `ddInstaller` will just install it.
- If `ddMenuBuilder` is already exist on your site, `ddInstaller` will check it version and update it if needed.

### Manually

[](#manually)

#### 1. Elements → Snippets: Create a new snippet with the following data

[](#1-elements--snippets-create-a-new-snippet-with-the-following-data)

1. Snippet name: `ddMenuBuilder`.
2. Description: `2.2 Simple and flexible template-driven menu builder.`.
3. Category: `Core → Navigation`.
4. Parse DocBlock: `no`.
5. Snippet code (php): Insert content of the `ddMenuBuilder_snippet.php` file from the archive.

#### 2. Elements → Manage Files:

[](#2-elements--manage-files)

1. Create a new folder `assets/snippets/ddMenuBuilder/`.
2. Extract the archive to the folder (except `ddMenuBuilder_snippet.php`).

Parameters description
----------------------

[](#parameters-description)

### Data provider parameters

[](#data-provider-parameters)

Providers get documents data to output.

- `provider`

    - Desctription: Name of the provider that will be used to fetch documents.
    - Valid values:
        - `'parent'`
        - `'select'`
    - Default value: `'parent'`
- `providerParams`

    - Desctription: Parameters to be passed to the provider.
    - Valid values:
        - `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
        - `stringHjsonObject` — as [HJSON](https://hjson.github.io/)
        - `stringQueryFormatted` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
        - It can also be set as native PHP object or array (e. g. for calls through `\DDTools\Snippet::runSnippet` or `$modx->runSnippet`):
            - `arrayAssociative`
            - `object`
    - Default value: —

#### Providers → Parent (`&provider=`parent` `)

[](#providers--parent-providerparent-)

Select children documents from required parent(s).

- `providerParams->parentIds`

    - Desctription: Parent IDs — the starting points for the menu. Specify '0' to start from the site root.
    - Valid values:
        - `array`
        - `stringCommaSepareted`
    - Default value: `'0'`
- `providerParams->parentIds[i]`

    - Desctription: Parent ID.
    - Valid values: `integerDocumentID`
    - **Required**
- `providerParams->depth`

    - Desctription: The depth of documents to build the menu.
    - Valid values: `integer`
    - Default value: `1`

#### Providers → Select (`&provider=`select` `)

[](#providers--select-providerselect-)

Just output selected documents.

- `providerParams->ids`

    - Desctription: Document IDs.
    - Valid values:
        - `array`
        - `stringCommaSepareted`
    - **Required**
- `providerParams->ids[i]`

    - Desctription: Document IDs.
    - Valid values: `integerDocumentID`
    - **Required**

### General parameters

[](#general-parameters)

- `sortDir`

    - Desctription: The sorting direction (by `menuindex` field).
    - Valid values:
        - `'ASC'`
        - `'DESC'`
    - Default value: `'ASC'`
- `showPublishedOnly`

    - Desctription: Show only published documents.
    - Valid values:
        - `0`
        - `1`
    - Default value: `1`
- `showInMenuOnly`

    - Desctription: Show only documents visible in the menu.
    - Valid values:
        - `0`
        - `1`
    - Default value: `1`

### Template parameters

[](#template-parameters)

- `templates`
    - Desctription: Templates.
        Placeholders available in all templates:
        - `[+id+]`
        - `[+menutitle+]` — will be equal to `[+pagetitle+]` if empty.
        - `[+pagetitle+]`
        - `[+published+]`
        - `[+isfolder+]`
        - `[+totalAllChildren+]`
        - `[+totalThisLevelChildren+]`
        - `[+level+]`
    - Valid values:
        - `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
        - `stringHjsonObject` — as [HJSON](https://hjson.github.io/)
        - `stringQueryFormatted` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
        - It can also be set as native PHP object or array (e. g. for calls through `\DDTools\Snippet::runSnippet` or `$modx->runSnippet`):
            - `arrayAssociative`
            - `object`
    - Default value: —

#### Item templates

[](#item-templates)

- `templates->item`

    - Desctription: The menu item template.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: `'@CODE:[+menutitle+]'`
- `templates->itemHere`

    - Desctription: The menu item template for the current document.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: `'@CODE:[+menutitle+]'`
- `templates->itemActive`

    - Desctription: The menu item template for a document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the `depth` parameter).
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->itemHere`
- `templates->itemUnpub`

    - Desctription: The menu item template for unpublished document (when `showPublishedOnly` == `0`).
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->item`
- `templates->itemUnpubActive`

    - Desctription: The menu item template for unpublished document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the `depth` parameter).
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->itemActive`

#### Parent item templates

[](#parent-item-templates)

- `templates->itemParent`

    - Desctription: The menu item template for documents which has a children displayed in menu.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: `'@CODE:[+menutitle+][+children+]'`
- `templates->itemParentHere`

    - Desctription: The menu item template for the current document when it has children displayed in menu.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: `'@CODE:[+menutitle+][+children+]'`
- `templates->itemParentActive`

    - Desctription: The menu item template for a document which has the current document as one of the children.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->itemParentHere`
- `templates->itemParentUnpub`

    - Desctription: The menu item template for unpublished documents which has a children displayed in menu.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->itemParent`
- `templates->itemParentUnpubActive`

    - Desctription: The menu item template for an unpublished document which has the current document as one of the children.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: = `templates->itemParentActive`

#### Outer template

[](#outer-template)

- `templates->outer`

    - Desctription: Wrapper template.
        Available placeholders:
        - `[+children+]` — Generated HTML with all items.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - Default value: `'@CODE:[+children+]'`
- `placeholders`

    - Desctription: Additional data has to be passed into the `templates->outer`.
        Arrays are supported too: `some[a]=one&some[b]=two` =&gt; `[+some.a+]`, `[+some.b+]`; `some[]=one&some[]=two` =&gt; `[+some.0+]`, `[some.1]`.
    - Valid values:
        - `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
        - `stringHjsonObject` — as [HJSON](https://hjson.github.io/)
        - `stringQueryFormatted` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
        - It can also be set as native PHP object or array (e. g. for calls through `\DDTools\Snippet::runSnippet` or `$modx->runSnippet`):
            - `arrayAssociative`
            - `object`
    - Default value: —

Examples
--------

[](#examples)

All examples are written using [HJSON](https://hjson.github.io/), but if you want you can use vanilla JSON instead.

### Providers → Parent

[](#providers--parent)

```
[[ddMenuBuilder?
	&provider=`parent`
	&providerParams=`{
		parentId: 1
		depth: 2
	}`
]]
```

### Providers → Select

[](#providers--select)

```
[[ddMenuBuilder?
	&provider=`select`
	&providerParams=`{
		ids: [
			1
			2
			3
		]
	}`
]]
```

### Pass additional data into outer chunk (the `placeholders` parameter)

[](#pass-additional-data-into-outer-chunk-the-placeholders-parameter)

```
[[ddMenuBuilder?
	&templates=`{
		outer:
			'''
			@CODE:[+children+][+somePlaceholder2+]
			'''
	}`
	&placeholders=`{
		class: someClass
		somePlaceholder2: Some value for placeholder.
	}`
]]
```

### Using Query string instead of JSON

[](#using-query-string-instead-of-json)

JSON syntax is more clear than Query string, but sometimes it's not convenient. For example, if you want to pass JSON string as string.

```
[[ddMenuBuilder?
	&provider=`parent`
	&providerParams=`parentId=1&depth=2`
	&templates=`outer=general_nav`
	&placeholders=`pladeholder1={"someName": "someValue"}&pladeholder2={"name": "John"}`
]]
```

### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval

[](#run-the-snippet-through-ddtoolssnippetrunsnippet-without-db-and-eval)

```
//Include (MODX)EvolutionCMS.libraries.ddTools
require_once(
	$modx->getConfig('base_path') .
	'assets/libs/ddTools/modx.ddtools.class.php'
);

//Run (MODX)EvolutionCMS.snippets.ddMenuBuilder
\DDTools\Snippet::runSnippet([
	'name' => 'ddMenuBuilder',
	'params' => [
		'providerParams' => [
			'parentId' => 1
		]
	]
]);
```

Links
-----

[](#links)

- [Home page](http://code.divandesign.ru/modx/ddmenubuilder)
- [Telegram chat](https://t.me/dd_code)
- [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddmenubuilder)
- [GitHub](https://github.com/DivanDesign/EvolutionCMS.snippets.ddMenuBuilder)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~577 days

Total

3

Last Release

1109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/09b81986267e62b5fde1473b40aa6f11f7bc26c1c29d5f80f2768c8788e08110?d=identicon)[dd](/maintainers/dd)

---

Top Contributors

[![Ronef](https://avatars.githubusercontent.com/u/1333424?v=4)](https://github.com/Ronef "Ronef (56 commits)")

---

Tags

modxMODX Evomenunavigationevoevolution-cmsmodx evolutionevo cmsevolutioncmsddmenubuilder

### Embed Badge

![Health badge](/badges/dd-evolutioncms-snippets-ddmenubuilder/health.svg)

```
[![Health](https://phpackages.com/badges/dd-evolutioncms-snippets-ddmenubuilder/health.svg)](https://phpackages.com/packages/dd-evolutioncms-snippets-ddmenubuilder)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
