# How to pass veriable data chunk to snippet

**URL:** <https://community.modx.com/t/how-to-pass-veriable-data-chunk-to-snippet/3273>\
**Category:** Random\
**Tags:** fred, hook, migx\
**Created:** [November 3, 2020, 1:12pm UTC](https://community.modx.com/t/how-to-pass-veriable-data-chunk-to-snippet/3273 "2020-11-03T13:12:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaikhjunaid2221](https://community.modx.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@shaikhjunaid2221](https://community.modx.com/u/shaikhjunaid2221)\
**Post date:** [November 3, 2020, 1:12pm UTC](https://community.modx.com/t/how-to-pass-veriable-data-chunk-to-snippet/3273/1 "2020-11-03T13:12:26Z")

</div>

Please tell me how can i pass variable value chunk to snippet … i m written HTML code in chunk and want to send my dropdown field value in snippet.

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [November 3, 2020, 1:30pm UTC](https://community.modx.com/t/how-to-pass-veriable-data-chunk-to-snippet/3273/2 "2020-11-03T13:30:56Z")

</div>

maybe this is, what you are asking for

> **[Templating - Writing Snippets](https://docs.modx.com/current/en/extending-modx/snippets/templating)**

---

<div class="post-metadata">

**Author:** ![bobray](https://community.modx.com/user_avatar/community.modx.com/bobray/32/46_2.png) [@bobray](https://community.modx.com/u/bobray)\
**Post date:** [November 3, 2020, 11:05pm UTC](https://community.modx.com/t/how-to-pass-veriable-data-chunk-to-snippet/3273/3 "2020-11-03T23:05:36Z")

</div>

It’s difficult to help without knowing where the variable’s value is coming from, but one method is to put the snippet tag where you want the chunk’s HTML to appear and a placeholder in the chunk for the value.

Placeholder:  
`[[+placeholder_name]]`

Snippet tag:  
`[[!SnippetName]]`

Then in the snippet, set the variable to the value and send that to `$modx->getChunk()` at the end of the snippet:

```auto
$myVariable = 'someValue';

return $modx->getChunk('chunkName', array('placeholder_name' => $myVariable));

```

MODX will return the chunk’s HTML with the placeholder replaced by the value of the variable.
