GoodNewsContentCollection Snippet

What is GoodNewsContentCollection?

GoodNewsContentCollection is a Snippet to output a formatted list of MODX Resource documents in the body of the mailing (in conjunction with a defined MODX Chunk). The list of Resource documents can be comfortably preselected in the GoodNews mailing editor while creating/editing a newsletter. GoodNewsContentCollection is comparable to the well known getResources Snippet.

This makes it very easy for editors to send, for instance, a list of actual news to their newsletter recipients without knowing on how to format the underlying HTML or the contained links to the articles on your website.

To use this Snippet, the activation of at least one Content Collection in the settings of the GoodNews container is required!

How to use the Snippet

You need to place the GoodNewsContentCollection Snippet in the body area of the Mailing where you'd like to get the listed the preselected Resources.

Default properties for the Snippet

The GoodNewsContentCollection Snippet implements the following properties:

Property Description Default
collectionId Internal name of the content collection (collection1, collection2 or collection3). collection1
tpl Name of a Chunk serving as template for a Resource row. NOTE: if not provided, properties are dumped to output for each resource. sample.GoodNewsContentCollectionRowTpl
tplWrapper Name of a Chunk serving as wrapper template for the Snippet output.  
sortby A field name to sort by or JSON object of field names and sortdir for each field, e.g. {"publishedon":"ASC","createdon":"DESC"}. publishedon
sortdir Order which to sort by. DESC
includeContent Indicates if the content of each resource should be returned in the results. 0=false
outputSeparator Separator for the output of row chunks. \n
toPlaceholder If set, will assign the result to this placeholder instead of outputting it directly.  
debug If true, will send the SQL query to the MODX log. false

An example GoodNewsContentCollection Snippet call would look like this:

    [[!GoodNewsContentCollection? &collectionId=`collection1` &includeContent=`1` &tpl=`sample.GoodNewsContentCollectionRowTpl`]]

Please have a look at the pre-installed newsletter template sample.GoodNewsNewsletterTemplate2 to see how the Snippet can be implemented.

GoodNewsContentCollection also comes with a default tpl Chunk named sample.GoodNewsContentCollectionRowTpl:

<table border="0" width="100%" cellpadding="0" cellspacing="0" class="collectionrow" bgcolor="#ffffff">
    <tr class="collectiontitle">
        <td bgcolor="#ffffff" style="background-color: #ffffff; padding-bottom: 5px; font-size: 18px; line-height: 24px; font-family: Helvetica, sans-serif; color: #333;">
            <a href="[[+url]]" style="color: #9ec41a;"><span style="color: #9ec41a;">[[+pagetitle]]</span></a>
        </td>
    </tr>
    <tr class="collectionbody">
        <td bgcolor="#ffffff" style="background-color: #ffffff; font-size: 16px; line-height: 22px; font-family: Helvetica, sans-serif; color: #333;">
            [[+content:notags:ellipsis=`200`:default=`[[+introtext:ellipsis=`200]]`]]
        </td>
    </tr>
</table>
<br>