putyourlightson / craft-campaign

Send and manage email campaigns, contacts and mailing lists in Craft CMS.
https://putyourlightson.com/plugins/campaign
Other
63 stars 25 forks source link

Documentation clarification: Getting Sendouts #461

Closed iparr closed 7 months ago

iparr commented 8 months ago

Here: https://putyourlightson.com/plugins/campaign#getting-sendouts

The following line in the code example does not seem to work:

{% set sendouts = craft.campaign.sendouts.sendoutType('sent').campaignId(5).all %}

However, changing this the following way does give the desirable results:

{% set sendouts = craft.campaign.sendouts.status('sent').campaignId(5).all %}

I'm just checking:

  1. If I have this right and it's worth updating the documentation.
  2. That it's safe to use this technique from campaign templates in the future, because it feels like a very handy way to get information about subsequent sendouts from campaign templates.

It would be nice to see craft.campaign.sendouts options documented more extensively (such as ordering, etc.) if at all possible because it looks like a really powerful template hook (for example, I am using craft.campaign.sendouts.status('sent').campaignId(campaign.id).one().sendDate to get the date on which a campaign was last sent.

bencroker commented 8 months ago

Thanks for reporting this.

  1. You’re right, I’ve changed it to .status('sent') in the docs.
  2. Yes, it’s safe to use.

As per the docs at https://putyourlightson.com/plugins/campaign#getting-sendouts:

In addition to supporting the parameters that all element types in Craft support (id, title, etc.), the returned Element Query also supports the following parameters.

This means that craft.campaign.sendouts, which returns an element query, can also take parameters such as status, orderBy, limit, offset, etc.

As for the properties and methods available on sendouts, I started documenting them only to realise that there are far too many to document. Craft doesn’t document all properties and methods on the core element types either, although they do exist in the class reference. So I’ve updated the docs to reference the appropriate class which contains all public properties and methods. See https://putyourlightson.com/plugins/campaign#outputting-sendouts

Let me know if that’s clear and if you see any more room for improvement.