I have JS that I need to have a count but it needs to start from 0 and not 1. Does anyone know how to do this. I would be fine just subtracting 1 from {count}but have not figured out how to do it.
Thanks
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
January 26, 2012 9:55am
Subscribe [2]#1 / Jan 26, 2012 9:55am
I have JS that I need to have a count but it needs to start from 0 and not 1. Does anyone know how to do this. I would be fine just subtracting 1 from {count}but have not figured out how to do it.
Thanks
#2 / Jan 26, 2012 10:30am
Hi akrug23,
What version of EE are you using?
Also, can you post your code so we can understand what you are trying to do please.
Thank you,
Mike
#3 / Jan 26, 2012 10:43am
Hi, akrug23 - this isn’t possible out of the box, it would require some PHP for sure. I’ve gone ahead and moved this down to Community Help for you for some more community input.
#4 / Jan 26, 2012 10:48am
I figured it out. I had to use JS to subtract 1 from the number that it printed out.
Basically I am working on a site that has a JS audio player on it and the JS was reading through an array and the array is being populated by EE. I was needing the position in the array to start at 0.
I am using EE 2 the newest version.
Here is the code.
{exp:channel:entries channel="artists" limit="1" disable="categories|category_fields|member_data|pagination"}
{a_mp3s}
{"position":"{count}","mp3":"{url}","trackinfo":"{author} | {title}","id":"{count}"}{if count != total_files},{/if}
{/a_mp3s}
{/exp:channel:entries}