This topic is locked

Creating Conditional View Modes

9/23/2011 2:05:48 AM
PHPRunner General questions
D
DigitalDean8 author

I have a PHPR project (5.3) that is a digital asset management tool. I have a variety of different types of files stored there such as Audio,Video,Images,Documents etc. Right now, they are all presented as just a "file" so that the user can download them if desired. What I would like to do is create a preview/viewer system that updates the correct viewer type based on the type of asset in the system. I already have the structure for that kind of logic working as it associates the correct kind of "ICON" based on the asset type. My question is, how can I dynamically change the "View As" type based on the value of another field in that record so that the correct "viewer" is called. Here is what my current asset type logic does:
if ($data["Asset_Media_Type"] == 'Video'):

$value = '<img src="images/video-icon.png" alt="" />';

elseif ($data["Asset_Media_Type"] == 'Audio'):

$value = '<img src="images/audio-icon.png" alt="" />';

elseif ($data["Asset_Media_Type"] == 'Image'):

$value = '<img src="images/image-icon.png" alt="" />';

elseif ($data["Asset_Media_Type"] == 'Document'):

$value = '<img src="images/document-icon.png" alt="" />';

elseif ($data["Asset_Media_Type"] == 'Highlight'):

$value = '<img src="images/highlight-icon.png" alt="" />';

endif;
Is there a way to make this work?
Thanks

Dean

C
cgphp 9/23/2011

I think the best way is to use a Custom field and check the media type, like you do for the icons, and show the correct viewer.