SHOWING A LINK TO UPLOADS ONLY IF THEY EXIST - Aug 3rd, 2010


chassa2556 asked about showing a link to a gallery on a page only when pictures are uploaded to the page on the back
end.

Dave came to the rescue again...

First you need to determine the name of your uploads variable. Usually it will look something like this:



$your_field_nameRecord['uploads']



Use your own field name in the example code below.

Next, you can use some code like this to test for uploads:



<?PHP if ($your_field_nameRecord['uploads']): ?>
... this HTML or PHP will be shown if there are uploads ...
<?PHP endif ?>



Just wrap those tags around the content you want to show. Make sure the content can be removed without breaking the page
design. For example if you put that around half a table and there was no uploads it would only show the bottom html for
the table.

Typically you'd put it around a entire table, tr, td, or block of code.

Along the same lines, you can add a ! for "not" to test if there are "not" uploads. Like this:



<?PHP if (!$your_field_nameRecord['uploads']): ?>
Sorry, there are no uploads.
<?PHP endif ?>



Dave went on to remind us that the best approach, as always is to create the working HTML pages first. Then get the link
working to open in a new page. Then wrap it in the if tags above so it only shows when there are actually images.



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service