2

I want to declare a variable that is capable of holding multiple values in Apache SSI. Then I want to iterate over the values and print them on the page.

Could I do that using regular expressions and recursive includes? Am I crazy, or could I make this work:

In index.html

<!--#set var="values" value="a,b,c" -->
<!--#set var="count" value="0" -->

<ul>
    <!--#include virtual="looper.shtml" -->
</ul>

in looper.shtml:

<!-- I need some sort of terminal condition -->
<!--#set var="value" value="use a regexp to get the value at values[count] (not sure how)" -->
<!--#set var="count" value="count + 1 (not sure how to do that either)" -->

<li><!--#echo var="value" --></li>

<!--#include virtual="looper.shtml" -->
Adam
  • 12,236
  • 9
  • 39
  • 44
  • While I am a huge fan of abusing tools for entertainment purposes, surely you could just throw together a short script to do this with the same (or less!) amount of effort? – larsks Mar 31 '12 at 00:51
  • Yeah I could just do a perl script but it would be a hassle to convince the webmaster to turn on exec-cgi privliges. – Adam Apr 03 '12 at 20:00

1 Answers1

0

Use RewriteRule and RewriteMap to concatenate values into a variable and print values respectively:

#Redirect a URI to an all-lowercase version of itself

RewriteMap lc int:tolower 
RewriteRule (.*[A-Z]+.*) ${lc:$1} [R] 

References

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265