D
D
Dmitry2017-03-03 08:51:57
PHP
Dmitry, 2017-03-03 08:51:57

How to put this php code into a snippet on modx?

Hello!
Zero in php. The template contains the following code. I just can't get it to fit properly into the snippet. Help me please

<?php foreach ($img as $i) { ?>
<div class="b11 v2" data-name="<?=$i?>" style="background-image: url('assets/app/temp/<?=$sid?>/<?=$i?>');" data-state="ok">
 <div class="a1"></div>
</div>
<?php } ?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2017-03-03
@bsloungespa

<?php
$text = '';
foreach ($img as $i) {
    $text .= '<div class="b11 v2" data-name="' . $i . '" style="background-image: url(\'assets/app/temp/' . $sid . '/' . $i . '\');" data-state="ok"><div class="a1"></div></div>';
}
return $text;

Z
zooks, 2017-03-03
@zooks

Read the manual, the question is trivial.
php.net/manual/en/ini.core.php#ini.short-open-tag

M
MisterN, 2017-03-03
@MisterN

https://docs.modx.com/revolution/2.x/developing-in...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question