We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14786
    • 57 Posts
    The way I’ve been using ditto is to create a chunk for a template and then if I need to include code use a snippet in the chunk. I find this can be rather cumbersome as I’m left with several different chunks and snippets to do simple calculations. Such as if I need a chunk to consider whether a template variable is active then I’d have to create a new snippet for that.

    I’m wondering if there is a way to bypass the chunks for ditto templating and just create one snippet.

    For example:
    Chunk Template:
    <h4>[+title+]</h4>
    <div class="description">[+content+]<br />[[snippetcall]]</div>


    Snippet Call:
    <?php
    if(something)
    return '<a href="#" class="underline">Learn more</a>';
    else
    return '';
    


    Its just a few lines of code in each and it creates the need to do a lot of clicking, loading, saving. It can create long trees of chunk->snippet that need to be tracked down for a small change. Itd be much easier for me to just put it all in one place.
      • 18397
      • 3,250 Posts
      One way to bypass code entirely is to use the PHx syntax.

      But, assuming you are quicker at typing PHP than PHx statements like I am, please file a ticket in the Ditto bugtracker to "Allow execution of PHP in chunks, passing the $resource variable along for referencing the parsed item’s retrieved documentObject."
        • 14786
        • 57 Posts
          • 18397
          • 3,250 Posts
          It would be great if you could refile it in the Ditto Bugtracker. Thanks.