Use GetToken!
Code: Select all
$views = <<<VIEWS
Details
Details with Thumbnails
List
Small Icons
Thumbnails #1
Thumbnails #2
Thumbnails #3
Large Icons
Small Tiles
Large Tiles
VIEWS;
Echo 'The current view is: ' . GetToken($views, Get('View')+1, "<crlf>");
EDIT: Though honestly, you're probably better off making
$views into a lookup table rather than relying on it being in the correct order:
Code: Select all
$views = <<<VIEWS
0|Details
1|Details with Thumbnails
2|List
3|Small Icons
4|Thumbnails #1
5|Thumbnails #2
6|Thumbnails #3
7|Large Icons
8|Small Tiles
9|Large Tiles
VIEWS;
// Filter the list of views by the current view index.
$view = FormatList($views, 'f', "<crlf>", Get('View') . '|*');
// Strip off the index value.
$view = GetToken($view, 2, '|', 't', 2);
Echo "The current view is: $view";
EDIT 2: And if you want to be even more awesome add the CIDs to your lookup table so you can retrieve the translated captions (where you could thus include accelerators or the user's shortcut keys).
Code: Select all
// List of Views
// Format is: ViewIndex|CommandID|Description
$views = <<<VIEWS
0|302|Details
1|303|Details with Thumbnails
2|304|List
3|305|Small Icons
4|306|Thumbnails #1
5|307|Thumbnails #2
6|308|Thumbnails #3
7|309|Large Icons
8|313|Small Tiles
9|314|Large Tiles
VIEWS;
// Get current view line.
$view = FormatList($views, 'f', "<crlf>", Get('View') . '|*');
// Get our description of view.
$ourCaption = GetToken($view, 3, '|', 't', 2);
// Get the translated menu caption of the view.
$cid = GetToken($view, 2, '|', 't');
$translatedCaption = Get('MenuCaption', $cid, 2); // 2 = strip accelerators
Echo "We call the current view: $ourCaption<crlf>But you might call it: $translatedCaption";