Use the recipe below to create a page, that will allow you to select existing nodes from a list and incorporate them in a Simplenews newsletter.
The page is based on a view. The selected nodes will be fed to a Rules component. This component will create a newsletter, and put the selected nodes in an entity reference field of the newsletter. The newsletter content type is configured to display the teasers of all referenced nodes.
Add an entity reference field to the newsletter content type (Content types > Simplenews newsletter > Manage fields).
- Field name: Articles (field_simplenews_articles)
- Field type: Entity Reference
- Widget: Inline entity form
Now click on the save button, on the next page set up the folling settings:
- Inline Entity Form: Allow users to add existing nodes
- Number of values: Unlimited
- Target type: Node
- Target bundles: Article (or whatever content type you would like to use)
- Sort by: nid or created (or whatever field you would like to use)
Now go to Manage display, and set the field Articles to
- Label: Hidden
- Format: Rendered entity (Rendered as Teaser)
Create a Rules component (Configuration > Workflow > Rules > Components).
- Name: Create newsletter
- Variables: A List of node items, labeled Articles, used as input parameter
- Create a new entity: type Node, content type Simplenews newsletter, title Newsletter
- Set a data value: selected data newsletter-created:field-simplenews-term, value: the newsletter category you would like to use
- Loop: data selector articles, current list item Article
Inside the loop:
- Add an item to a list: list newsletter-created:field-simplenews-articles, item to add article
- Save entity: entity newsletter-created, Force saving immediately true
- Page redirect: URL [newsletter-created:url]
Create a view with a page display.
- Format: table
- Bulk operations: Content with Selected operations Create newsletter (rules_create_newsletter)
- Content: Title
- Filter criteria:
- Content: Published (Yes)
- Content: Type (= Article)
- Sort criteria: Content: Post date (desc)
- Page settings / Access: Permission | Simplenews newsletter: Create new content
Inline entity form
Inline entity form is a module created for the commerce module, it's mostly used to add products to a product display, but it also works great for adding other nodes to a newsletter and offers a way to order the list that is created via the VBO view provided on this post.
- You could add a hidden boolean field to the Article content type. The Rules component would set this to TRUE, and the view would filter on this field being FALSE. Thus the view would only show articles not yet published in a newsletter.
- Using Rules Scheduler you could automatically create and send a newsletter containing all new articles from last week or month.
TODO: add a way to change the order of articles in a newsletter (using the Weight module or DraggableViews)Done, see Inline Entity Form