Fall-back image puzzler....?

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 10, 2012   (RSS)

By Perchpole - September 10, 2012

Hello, All -

Every time someone posts a record on the site they have the option of selecting a themed icon. They get to choose from one of a number of entries on a list - which might denote News, Article, Review, etc.

If they don't choose an icon, the system is designed to use the icon associated with category to which the record has been added.

It all works fine. The only problem is if (for some reason) no one has added a category icon. In which case there is no fall-back option and an rror is generated.

This is the code I'm using:

<?php if ($record['icon']): ?>
<?php $recordTheme = mysql_get('icon_list', $record['icon']); $recordThemeIcon = getUploadRecords('icon_list', 'icon', $recordTheme['num']); ?>
<?php $recordIcon = $recordThemeIcon[0] ?>
<?php else: ?>
<?php $recordThemeIcon = getUploadRecords('category', 'icon', $record['category']); ?>
<?php $recordIcon = $recordThemeIcon[0] ?>

<?php endif ?>

What I would like to do is to change the else statement into an elseif statement and then test to see if the category icon has been uploaded. If no icon is present then the code would fall-back to a default icon.

:0/

Perch