- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I’m trying to display a number next to each article with the following code in Kirby.
$count = 0;
foreach($page->children()->visible()->flip() as $article):
$count++
?>
However, it’s outputting like this
`1 Latest Article`
`2 Older Article`
I need it to output like this
`2 Latest Article `
`1 Older Article`
Maybe set the counter to the highest number, and count down.
I took a peek at the Kirby API cheat sheet I came up with this.
$count = $page->count();
foreach($page->children()->visible()->flip() as $article):
$count–;
?>
@hotpink I had to change your code as it was counting all the pages, I think (it started from 16).
$count = $page->children()->count();
This echos out 0 for the first article where I need it to echo out 1.
Nice @benwalker. Thank you!
Edit: Also, thank you @hotpink
@BenWalker Your code works perfectly.
down
wow, code parser is terrible on this site. nvm my help
http://pastebin.com/h7aCGq0d