21285 Posts in 5732 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » (solved)How to random include files (in include folder)
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 570 Views |
-
(solved)How to random include files (in include folder)

20 March 2011 at 4:09am
Hi what function do i need to write into Page.php and how to add it on template if i wanna randomly include .ss files from include folder named 1.ss, 2.ss, 3.ss, 4.ss, 5.ss, 6.ss .
Tryed:
in Page.php:
function RandomNumber() {
return rand(1, 6);
}and
in Page.ss:
<% include $RandomNumber %>but it didnt work just saw in template after flushing : <% include 4 %> but it didnt call the including just generated text like so where i was going wrong
-
Re: (solved)How to random include files (in include folder)

20 March 2011 at 4:19am
so it works: if i use the page.php as it is
<% if RandomNumber == 1 %>
<% include 1 %>
<% else_if RandomNumber == 2 %>
<% include 2 %>
<% else_if RandomNumber == 3 %>
<% include 3 %>
<% else_if RandomNumber == 4 %>
<% include 4 %>
<% else_if RandomNumber == 5 %>
<% include 5 %>
<% else_if RandomNumber == 6 %>
<% include 6 %>;
<% end_if %>
| 570 Views | ||
|
Page:
1
|
Go to Top |

