📜 ⬆️ ⬇️

SSI loop - Loops in SSI

Despite the fact that the technology SSI (Server Side Includes) is not popular, especially with the advent of CMS. Nevertheless, it is convenient enough to create small sites without a complex structure. Even for those who have virtually no programming skills, it allows you to build a site based on templates. A lot of articles have already been written about this (and often copied). In addition to inclusions, SSI has conditional operators, and to a little bit of the programming language, it lacks mathematics, cycles and arrays. I decided to deal with one of these problems, cycles. Here's what I got.

The idea itself can be described in one word - recursion. In order not to rumble, I’ll just give listings with a small description, those who are familiar with SSI can figure it out without difficulty, and the rest should first learn the basics of SSI .

So for the organization of the cycle, you will need to create 2 files: the caller and the body of the cycle:
test-lloop.shtml
 <! - # set var = 'i' value = '1' ->
 <! - # set var = 'k' value = '1' ->
 <! - # set var = 'j' value = '111' ->
 <! - # include virtual = 'ssi-loop.shtml' ->

where the variables are:

test-loop.shtml
  <! - # if expr = "$ i <= $ j" ->
 everything you want to do in a loop
 <! - # set var = "i" value = "$ {i} $ {k}" ->
 <! - # include virtual = 'ssi-loop.html' ->
 <! - # endif -> 

In the body you will prevent any actions you need.

I practically haven't used it yet. Since there are no arrays, it is possible to muddle something with variables that differ in "step" and processing the parameters of the address bar
<! - # include virtual = "$ QUERY_STRING" ->.
')
PS
For those who are interested in SSI technology, I suggest to look at the article SSI + RewriteEngine .
While not ready examples of practical implementation, therefore, for a separate habrapost, does not hold out.

Source: https://habr.com/ru/post/140182/


All Articles