0

I need my [[+idx]] tv to start at 0 instead of 1 so I tried this: [[+idx:decr]] or [[+idx:substract=1]] but it gives me -1 (minus one). Does anyone know another way to obtain 0?

Thank you

curveball
  • 4,320
  • 15
  • 39
  • 49
Sylvain Le Bihan
  • 163
  • 1
  • 2
  • 13

2 Answers2

1

Using this in chunk for getImageList works (at least for me):

[[+idx:decr]]

It gives: 0,1,2,3 ....

P.S. using modx revo 2.3.1

TomoMiha
  • 1,218
  • 1
  • 14
  • 12
0

set your template variable default to 0 when you create the variable.

What are you trying to do, your question is vague at best.

UPDATE

ok - what I think will work for you is to write a snippet to do the math... where ever you call the [[+idx]] instead write a snippet

 [[!FixIDX? &itemindex=`[[+idx]]`]]

then in your FixIDX snippet just do the math with php and return the corrected index. Though perhaps a custom output modifier would be the better way to go: http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+(Output+Modifiers)

Though looking at the docs, your code should certainly work - I see no reason for it not to.

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
  • ok, sorry i thought it was pretty clear. I created a news system with text, title and link in each news. [[+idx]] is the id of each migx's news. Tv's are created like this with migx for example:{"field":"image","caption":"image","inputTVtype":"image"}, {"field":"titre_actu1","caption":"Titre de l'actualité 1"}, {"field":"actu_date1","caption":"actu_date1","inputTVtype":"date"},So tv"s doesn't really exists physicaly. Now i need to display the id of each news but it must start at 0, i have no other choice to get compatible with an other system. So i want to know if there is an other way. – Sylvain Le Bihan Mar 15 '13 at 01:31
  • hm so migx is creating the idx variable? hmm. I'll update my answer [maybe 'vague was a bit harsh, knowing you were using migx was pretty important.] – Sean Kimball Mar 15 '13 at 03:14
  • Is there a way to do something like that in a snippet : if ([[+idx]]==1) echo "0"; – Sylvain Le Bihan Mar 16 '13 at 17:53