PHPackages                             dd/evolutioncms-snippets-ddgetchunk - 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. dd/evolutioncms-snippets-ddgetchunk

ActiveModxevo-snippet

dd/evolutioncms-snippets-ddgetchunk
===================================

Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.

2.4.0(3y ago)01PHPPHP &gt;=5.6.0

Since May 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (9)Dependencies (1)Versions (6)Used By (0)

(MODX)EvolutionCMS.snippets.ddGetChunk
======================================

[](#modxevolutioncmssnippetsddgetchunk)

Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.

Also it can:

- Pass additional data to chunk for parsing.
- Escape special chars for JS.
- Remove empty placeholders.

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.60

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.ddGetChunk
\DDInstaller::install([
	'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetChunk',
	'type' => 'snippet'
]);
```

- If `ddGetChunk` is not exist on your site, `ddInstaller` will just install it.
- If `ddGetChunk` 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: `ddGetChunk`.
2. Description: `2.4 Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.`.
3. Category: `Core`.
4. Parse DocBlock: `no`.
5. Snippet code (php): Insert content of the `ddGetChunk_snippet.php` file from the archive.

#### 2. Elements → Manage Files

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

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

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

[](#parameters-description)

- `name`

    - Desctription: Chunk name or code via `@CODE:` prefix.
    - Valid values:
        - `stringChunkName`
        - `string` — use inline templates starting with `@CODE:`
    - **Required**
- `placeholders`

    - Desctription: Additional data has to be passed into the chunk.
        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: —
- `removeEmptyPlaceholders`

    - Desctription: Placeholders which have not values to be replaced by will be deleted from parsed chunk if the parameter equals 1.
    - Valid values:
        - `0`
        - `1`
    - Default value: `0`
- `escapeResultForJS`

    - Desctription: Escaping special chars for JS.
    - Valid values:
        - `0`
        - `1`
    - Default value: `0`

Examples
--------

[](#examples)

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

### Get content of the form into JS code

[](#get-content-of-the-form-into-js-code)

```

	var form = '[[ddGetChunk? &name=`someForm` &escapeResultForJS=`1`]]';

	//Insert form to page
	$('body').append(form);

```

### Get chunk with Ditto and send necessary additional data into it

[](#get-chunk-with-ditto-and-send-necessary-additional-data-into-it)

```
[[ddGetChunk?
	&name=`someChunk`
	&placeholders=`{
		id: 33
		orderBy: "someTv ASC, pub_date DESC"
	}`
]]

```

Code of `someChunk`:

```

		[[Ditto?
			&startID=`[+id+]`
			&orderBy=`[+orderBy+]`
			&tpl=`someChunk_item`
		]]

```

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

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

```
\DDTools\Snippet::runSnippet([
	'name' => 'ddGetChunk',
	'params' => [
		'name' => 'someChunk'
	]
]);
```

Links
-----

[](#links)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~369 days

Total

4

Last Release

1100d ago

PHP version history (2 changes)2.2.1PHP &gt;=5.4.0

2.3.0PHP &gt;=5.6.0

### 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 (31 commits)")

---

Tags

modxMODX Evoevoevolution-cmsmodx evolutionevo cmsevolutioncmsdivandesigndd studiodd groupddgetchunkget chunkparse chunk

### Embed Badge

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

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

PHPackages © 2026

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