We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37059
    • 368 Posts
    I know how to pass a value from a snippet to the chunk that contains its presentational information.

    Here is an example illustrative of my situation:

    Snippet A lists a number of items using Chunk B as a template.

    Depending on the type of item, determined by Snippet A through examination of the database, certain header information in the chunk may need to be added or removed.

    For example, suppose I am selling two kinds of products, T-shirts and coffee cups. It would not make sense for my display chunk to have a header for "Length" if the item is a coffee cup or for "Capacity" if the item is a shirt - even if these headers had blank information.

    Keeping in mind that I can’t put PHP code in the chunk, how can I effectively pass the information from snippet to chunk as to what content should be presented?

    Any help would be appreciated.


      Jason
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you’re using placeholders, your snippet can conditionally put the whole header into the placeholder. Having the placeholder in the chunk in that case wouldn’t do anything if there was nothing for it to do; MODx has garbage collection to remove unused placeholder tags.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 37059
        • 368 Posts
        Quote from: sottwell at Jul 08, 2010, 03:44 PM

        If you’re using placeholders, your snippet can conditionally put the whole header into the placeholder.
        Wouldn’t that be putting presentational information in a snippet?
          Jason
          • 29019 ☆ A M B ☆
          • 104 Posts
          The placeholder content could also come from another chunk or a TV. You could set it up a more generic chunk:

          <div class="header">[+header+]</div>
          <div class="body">[+more+][+placeholders+][+here+]</div>


          Then have a few different chunks for header options, then in your snippet choose the appropriate header chunk and throw it into [+header+].
            www.darkstardesign.com

            Are you in the Nashville area? Join us for our next MODX meetup!
            • 37059
            • 368 Posts
            Quote from: swespi at Jul 16, 2010, 11:03 PM

            Then have a few different chunks for header options...
            Chunk proliferation could occur quickly smiley

            Thanks for the input. As I get more experience with Modx I’m finding this question isn’t so important after all.
              Jason