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
-
☆ 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.
-
☆ 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+].