Counters

Search
Feedback

The concept of counters in Structr is very similar to the counters in LaTeX. Counters are a numbering mechanism for nested objects, like chapters, lists etc. In Structr, counters allow you to create an automatic numbering of subsequent elements in an HTML page or document.

Counters are often used in conjunction with Repeater Elements.

Normally, a user would do something like this:

<h1>Chapter ${inc_counter(1, true)}${get_counter(1)}</h1>
<h2>Section ${inc_counter(2)}${get_counter(1)}.${get_counter(2)}</h2>
<h2>Section ${inc_counter(2)}${get_counter(1)}.${get_counter(2)}</h2>
<h1>Chapter ${inc_counter(1, true)}${get_counter(1)}</h1>
<h2>Section ${inc_counter(2)}${get_counter(1)}.${get_counter(2)}</h2>
<h2>Section ${inc_counter(2)}${get_counter(1)}.${get_counter(2)}</h2>

which results in the following output:

Chapter 1

Section 1.1

Section 1.2

Chapter 2

Section 2.1

Section 2.2

Graph-Browser

About this article
Last change 2017-02-24
Topics FrontendStructr 2.0