Hi,
I started with Modx a week ago and i’m strugling with the most simple things.
I have news items:
- news(1)
- Sport(2)
- item1
- item2
- ...
- Educational(3)
- item1
- item2
- ...
I show a list of all the newsitems, i would like to put a small image in front of it. Its a different image depending if its Sport or Educational.
Normally i would just do something like:
<?php
$fotoid = [*parentid*]
if ($fotoid == 2 ){
echo "<img src=’sport.jpg’/>";
}
else {
echo "<img src=’educational.jpg’/>";
}
?>
But i cant put php code in my Ditto chunks.
Can any1 explain where i put my code? Or maybe there are different ways on doing this?
Thanks in advance,
make use of phx in your Ditto-chunk:
[+parent:is=`2`:then=`<img src='sport.jpg'/>`:else=`<img src='educational.jpg'/>`+]
or try this:
create a image-TV with default-value @INHERIT, name it myimage
choose an image in manager for your parents and use it in your ditto-chunk like that:
not sure, if @INHERIT works in Ditto, but then you can use the getField-snippet to get TVs