Helge
1
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
Helge
3
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:
<?php
echo str_pad($project->num()->value(), 2, "0");
Helge
5
Thx again and again This forum is great
Helge
6
<?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"); ?>
</span>
<a class="item-inline--block no--underline" href="<?php echo $project->url() ?>">
<?php echo $project->title()->excerpt(26) ?>
</a>
<span class="index-columns--date"><?php echo $project->date('Y') ?></span>
</li>
<?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);
http://php.net/manual/en/function.str-pad.php
Helge
8
Nice, now it works properly