[gf_include_random]

Description

Link: [gf_include_random]
Author: Gaetano Frascolla
Category: Include
Version: 8.x
License: Public Domain
Posted: Oct. 24, 2007
Updated: Jan. 01, 0001
More by this author...
This tag returns a random element included in a determined directory. It can be used to include random images or pages.

Parameters

-path string, required

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

Email:


Password:



Newest

Most Popular