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

    Hi there,

    I’m using the Ditto snippet to generate an archive of individual events on an events landing page. Ditto does a great job of doing this.

    I wrote a custom snippet (called format_event_datetime) that formats the date of an event (based on whether certain fields in the individual events are populated) and tried to use this snippet in the template (’tpl’ param) of Ditto. The ditto call is:

    [!Ditto? &summarize=`3` &tpl=`events_ditto_tpl` &paginate=`1`!]

    And the events_ditto_tpl chunk/template looks like:

    [!format_event_datetime? &start_date=`[*tvstart_date*]` &end_date=`[*tvend_date*]` &start_time=`[*tvstart_time*]` &end_time=`[*tvend_time*]`!]

    where the various tv* params are date and time fields in the individual events template.

    I’ve tried both the cache ([!...!] and non-cached ([[...]]) syntax in the call to format_event_date_time. The former just spits out the snippet code verbatim; the latter, doesn’t output anything.

    Any idea???

    thanks!
    Steve
      • 10449
      • 956 Posts
      Does the snippet work on its own, i.e. not inside any Ditto call?
        • 1972
        • 15 Posts
        Hi Ganesh,

        If you’re referring to the format_event_datetime snippet -- yes, it does work on its own. Any other ideas? (the Ditto call works also, but the output of format_event_datetime isn’t parsed)

        thanks,
        Steve
          • 29181
          • 480 Posts
          I doubt it very much but does:

          [!Ditto? &summarize=`3` &tpl=`[[format_event_datetime? &start_date=`[*tvstart_date*]` &end_date=`[*tvend_date*]` &start_time=`[*tvstart_time*]` &end_time=`[*tvend_time*]`]]` &paginate=`1`!]


          or

          [[format_event_datetime? &start_date=`[*tvstart_date*]` &end_date=`[*tvend_date*]` &start_time=`[*tvstart_time*]` &end_time=`[*tvend_time*]`]]

          (calling the snippet uncached) work?

          On a sidenote (I don’t know what your format_event_datetime snippet is doing), ditto can output date formats and even tv values, which has always sufficed for me in the past without the need for a second snippet call. I’m not saying this is always the case, but it may be worth looking into.

          Hope that helps,
          Taff


            Adrian Lawley: www.adrianlawley.com
            • 36592
            • 970 Posts
            I think it should be...
            [[format_event_datetime? &start_date=`[+tvstart_date+]` &end_date=`[+tvend_date+]` &start_time=`[+tvstart_time+]` &end_time=`[+tvend_time+]`]]
            

              • 1972
              • 15 Posts
              Thanks for the help everyone! It works now! As tkfm pointed out, I was using the wrong delimiters for the placeholder (ie, [**] rather than [++]) and also having to alternate the snippet tag when nesting (I guess this is some form of nesting) snippets.