Florian,
Content added to the system is assigned a unique Global Identifier, which is not sequential, and for most purposes is superior to an autoincrement for accessing a specific piece of data.
When you do a dotContent pull, you can order by iDate (which is, as far as I can tell the initial creation date) and then use a counter within the loop to generate fake numbers that would be consistent. modDate would work as well, but that changes when an item is touched, so is less perfect for long term referrals.
Something like this:
#set ($id=$request.getParameter("id"))
#set ($counter=0)
#foreach($con in $dotcontent.pull("+structureName:Viewbook",0,"Viewbook.iDate desc"))
##Put this later in the loop if you want to start with an item 0
#set ($counter=$counter+1)
#if ($UtilMethods.isSet($id))
#if ($counter==$id)
##THIS IS THE SELECTED ITEM
$con.title
#end
#end
##If no id, display a list of all the items with their id.
#if (!UtilMethods.isSet($id))
<a href="?id=$counter">$con.title</a><br>
#end
#end
But what really matters is WHY you need these integer autoincrements? This would give you a code that would be consistent across time unless a piece is unpublished/deleted. You could actually count the unpublished ones as well, as your pull can get the unpublished items and count through them but only show published items. This would also insure no 'gaps' when an item is removed.
Mark Pitely
Marywood University