We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37909
    • 153 Posts
    Hi all!

    I want to insert HTML code every 3 documents inserted by Ditto.
    Example:
    I have seven documents (e.g. doc1, doc2, etc. it's easier to explain). This in my template:
    [!Ditto? &orderBy=`nomTV ASC` &tpl=`chunk_ditto`!]

    On the HTML preview page that will give:
    doc1
    doc2
    doc3
    doc4
    doc5
    doc6
    doc7

    But I wish that every 3 documents Ditto inserts something. So:
    doc1
    doc2
    doc3
    mypeiceofcode
    doc4
    doc5
    doc6
    mypeiceofcode
    doc7


    Help me please! [ed. note: neoziox last edited this post 12 years, 5 months ago.]
      • 16278
      • 928 Posts
      A little modulo maths using PHx's math modifier in your regular chunk will insert text (or a chunk) at the end of every third item, using the ditto_iteration placeholder as the index:
      [+ditto_iteration:math=`? % 3`:eq=`2`:then=`your chunk/piece of code`+]


      This should be added at the end of the tpl chunk.
      :) KP [ed. note: kp52 last edited this post 12 years, 5 months ago.]
        • 37909
        • 153 Posts
        It's great! That's work perfectly!