I’m having some trouble figuring this out. I’m using a jquery plugin (Scrollit) to scroll to parts of the page but i need to get Kirby to help out a little.
It works by giving elements and id in a data attribute: data-scroll-index="INDEXNUMBER"
Then you can scroll to it by putting a data attribute on an anchor tag: data-scroll-goto="INDEXNUMBER+1"
But this is in a foreach loop with Kirby Builder in it, so i need to get Kirby to automatically populate the INDEXNUMBER for me, and for the link tag it needs to add 1 to it, since this will make scroll on to the next builder panel on the page.
My code looks like this (some of it is slightly fake to illustrate what i need in words).
How do i get Kirby to count the number of items in the foreach loop and fill in the numbers, and also how would i get to start from a set number? Some pages already have these numbers hard coded further up the page so i might to start the numbering on the builder panels from an arbitrary number.
I’m having a similar problem, and while I found a workaround, I would like to know why I had to find it.
I’m doing a foreach loop, and setting a counting variable at the beginning ($n=0) and adding the (n++); to the line to iterate by one. In the first layout, it should give me a result of “0” for the value, shouldn’t it?
Here’s the code, with my solution to fix it (named $carl, go figure):
Just saw it, and thank you, that helps immensely. I’m really impressed by Kirby and all it can do. I’m currently building the pieces for the components of Bootstrap 4 as a way to learn the system and to get them all ready for use, too. Cheers!