Just to check whether this worked without further tinkering, I copied the code data-page-id="<?php echo $ID ?>"
into the body tag of the dokuwiki default theme. It works perfectly, no javascript required. Simple solution.
@andi The reason I wanted this function was that I need to style certain content according to what "section" it is in. Such functionality entered WordPress with the Sandbox theme 13 year ago, and later the functionality was integrated into core. Being able to style posts from a certain hour or day, people once considered cool.
With the HTML data-* attribute, one can target page id beginning with, containing, or ending with.
For example, if I want to style all my blog posts from January with a winter picture, and my blog folder looks like blog/2015/01/31.txt
then I would target beginning with blog:
and containing :01:
, like this:
body[data-page-id^="blog:"][data-page-id*=":01:"] {
background: blue;
}
I can think of many other uses, but they remain hypothetical. Since one of DokuWiki's unique features is hierarchy in folders, I guess a lot of developers will be happy to have such functionality, even if they don't know it yet.