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

    I am looking to write a chunk and I am not sure if logic goes into the snippet, the chunk or someplace else?
    Say I have a menu for today and my snippet will return breakfast, lunch and dinner if they exist. If not
    the snippet will return nothing. How do I only show breakfast and dinner if lunch is empty?

    The snippet returns a file name of a pdf.

    Here is the Chunk:

    <p><a href="/assets/files/menus/[[+breakfast]]">Breakfast</a> | <a href="/assets/files/menus/[[+lunch]]">Lunch</a> | <a href="/assets/files/menus/[[+dinner]">Dinner</a></p>

    Placeholders

    [[+breakfast]]

    [[+lunch]]

    [[+dinner]]
      • 29019 ☆ A M B ☆
      • 104 Posts
      I would use a chunk and some output filters, like so:
      [[+breakfast:notempty=`<a href="/assets/files/menus/[[+breakfast]]">Breakfast</a>`]]


      If you want to check something specific (not just empty), you might try the If snippet:
      [[If?&subject=`[[+breakfast]]`&operator=`equals`&operand=`bacon`&then=`<a href="/assets/files/menus/[[+breakfast]]">Breakfast</a>`]]
        www.darkstardesign.com

        Are you in the Nashville area? Join us for our next MODX meetup!
        • 36723
        • 94 Posts
        Thanks that is exactly what I needed.