O
O
Oleg2017-09-08 13:05:36
MODX
Oleg, 2017-09-08 13:05:36

How to pass a variable to a snippet?

Snippet code snippetName:

<?php
return number_format($price, 0, '', ' ' );

Chunk code:
{var $totalproducts = $_modx->config.clientstotal}
    <h2>{$totalproducts}</h2>

$totalproducts is a number. I need to pass this number to the snippet and return the result. I tried doing this:

But it doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
display: block, 2017-09-08
@qork

&price

A
Alex-1917, 2017-10-12
@alex-1917

Are you formatting the number with a snippet? Oooooh
This is how I round up to an integer, for example, in the placeholder cost was 73,897 became 74
Or write your own modifier: 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question