Hi everyone
First please excuse my ignorance. I’m new to MODx (been using it a little over 2 weeks now), I’m also not very savvy in PHP. So far MODx is great and I’m relay enjoying learning it. I have a web site I’m working on that has two columns, one with content and the other with images. Up until now I have just be creating many different templates depending on how many images I want in the image column, but this isn’t very clean and adds an extra step for the end user (choosing the correct template). Also now I’m trying to create an image gallery template and same as my image columns I don’t want to create multiple templates depending on how many images I want.
So today I decided I would try write a simple snippet that checks my template variables, and if they are null ignores them, but if they have a value it would echo the formating code I want. I tried this code:
<?php
/* Set up the PHP variables with template variable values */
$image_1 = [*galleryimage1*];
if ( $image_1 == null ) {
echo "";
} else {
echo "<li><img src="[*galleryimage1*]" alt="[*galleryalt1*]" /></li>";
}
?>
Unfortunately this dousn’t work, I’m assuming MODx has some special syntax for using TVs and such in Snippets. Like I mentioned I’m a noob at both PHP and MODx, so any help you can give would be great. I have spent a lot of time searching the web, these forms and the documentation but haven’t found anything that answers my questions. Thanks in advance - Jeff