Username Password
Bookmark and Share

Random Visible Asset Proxy macro

The RandomAssetProxy macro that comes with WebGUI will sometimes show no content at all if it is used to select among assets with varying view permissions. This is because the RandomAssetProxy macro selects a random asset BEFORE determining whether the asset is visible to the viewer. If the asset chosen happens to not be visible to that viewer, no output is returned.

This RandomViewableAssetProxy macro is a variation on the RandomAssetProxy macro, created for instances when you want to ensure that a visible asset is always returned. Basically, the RandomViewableAssetProxy macro FIRST checks all the potential assets for whether they can be viewed, THEN selects one of the visible assets at random. If none of the assets are visible to the viewer, the macro returns no results by default, though the macro can be easily modified to return some other results, if desired.

This macro is slightly more processor intensive than the original because each potential asset is instantiated in order to check whether it is visible. The RandomAssetProxy macro simplifies things by only instantiating the chosen asset.

Use the macro exactly as you would the RandomAssetProxy macro: place it on the page where you want the asset to appear and pass to it the URL of the parent asset under which a random child will be selected.

DownloadRandomVisibleAssetProxy_pm.txt RandomVisibleAssetProxy_pm.txt
LinksNo Support Offered
Statistics Downloads: 1366
Views: 6183
Rating: 0
Updated: 5/21/2011
NavigationMore from Trex
Back to the Bazaar
© 2023 Plain Black Corporation | All Rights Reserved