[gf_include_random]
Description
This tag returns a random element included in a determined directory. It can be used to include random images or pages.
Parameters
Sample Usage
<img src="[gf_include_random:'/image/']">
[include:(gf_include_random:'/path/')]
Source Code
Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
define_tag:'gf_include_random', -optional='path';
if:(local_defined:'path')&&(file_exists:(#path));
var:'array_path'=(File_ListDirectory: (#path));
var:'size_path'=($array_path)->Size;
var:'array_clean_path'=(Array);
loop:($size_path);
var:'element'=($array_path)->(get:(loop_count));
if:!(file_isdirectory:($element));
$array_clean_path->(insert:($element));
/if;
/loop;
var:'size_clean_path'=($array_clean_path)->Size;
var:'include_number'=(Math_Random: -Min=1, -Max=($size_clean_path)+1);
var:'element_include'=($array_clean_path)->(get:($include_number));
var:'result'=(#path)+($element_include);
return:($result);
/if;
/define_tag;
Comments
none