Kirby number format, num()

Hi Kirby forum,

I use

<span class="index-columns--number"><?php echo $project->num() ?></span>

to number a list of items. I’d like to have another number format.
Instead of 1,2,3,4… i’d like to have 01,02,03,04…

Is there a quick solution possible?

Thx in advance

sorry, but i don’t get it.

<?php echo $project->str_pad() ?> does not work. But thx for your answer anyway

No, not like that, like this:

echo str_pad($project->num()->value(), 2, "0");

Thx again and again :slight_smile: This forum is great

					<?php foreach ($page->children()->visible() as $project): ?>
						<li class="position--relative">
							<span class="index-columns--number"><?php
							echo str_pad($project->num()->value(), 2, "0"); ?>

							<a class="item-inline--block no--underline" href="<?php echo $project->url() ?>">
								<?php echo $project->title()->excerpt(26) ?>
							<span class="index-columns--date"><?php echo $project->date('Y') ?></span>
					<?php endforeach; ?>

Seems not to work. Maybe because of the loop?

Seems like num() already returns a string, so try this:

echo str_pad($project->num(), 2, "0", STR_PAD_LEFT);

Nice, now it works properly