KnpLabs / KnpMenu

Menu Library for PHP

Home Page:https://knplabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Label with hierarchical numbering 1.2.2.1

flaushi opened this issue · comments

I am using the ListRenderer to create a table of contents for a webpage (actually I use https://github.com/caseyamcl/toc and th OrderedListRenderer).

Using some CSS pseudo elements, I am able to get hierarical numbering dynamically:

<style>
		ol {
			list-style-type: none;
			counter-reset: item;
			margin: 0;
			padding: 0;
		}
		ol > li {
			display: table;
			counter-increment: item;
			margin-bottom: 0.6em;
		}
		ol > li:before {
			content: counters(item, ".") ". ";
			display: table-cell;
			padding-right: 0.6em;
		}
		li ol > li {
			margin: 0;
		}
		li ol > li:before {
			content: counters(item, ".") " ";
		}

Gives something like:
image

But would it be possible to compute and render these "addresses" and set them as value attribute in the created list? Like here https://www.w3schools.com/tags/att_li_value.asp

<li value="2.1">Übersicht</li>

Thanks in advance! Stay healty!