A newsletter with multiple related contents layout
| Project: | RelatedContent |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I had the request to have a simplenews newsletter that (1) could obtain contents directly from the site's own content, and (2) the site administrator could choose between three different newsletter layouts. Step one can be easily achieved via relatedcontend module, but step 2 meant doing some tweaks to relatedcontent.module.
I had great benefits from Michelle's post and TBarregren inclusion of Michelle's suggestion in relatedcontent.module. However the $vars['node']->relatedcontent, which gets the value of the 'parent' node (the node which the related contents are about) is only available to the system when it comes to use a callback for single relatecontent nodes. However for my needs I had to receive this value BEFORE, that is, at least inside theme_relatedcontent() function.
So, at line@461 I changed from:
$output = theme('relatedcontent', $output, $output_grouped, $node->type, $teaser, $page);
to:
$output = theme('relatedcontent', $output, $output_grouped, $node->type, $teaser, $page, $node->nid);
and then I changed line@189 from:
function theme_relatedcontent($output, $grouped = null, $node_type = null, $teaser = null, $page = null) {
to:
function theme_relatedcontent($output, $grouped = null, $node_type = null, $teaser = null, $page = null, $parent) {
and line@201 from:
$variables = compact('output', 'grouped', 'node_type', 'teaser', 'page');
to:
$variables = compact('output', 'grouped', 'node_type', 'teaser', 'page', 'parent');
This way, I made available to relatedecontent.tpl.php the nid of my newsletter node and with this value I can easily retrieve the layout assigned by the administrator (added via a cck field) and then perform different grouping actions depending on the selected layout type.

#1
+1 on the idea of layout options, but would want something relatively easy for (non developer) content editors to use. What about some sort of integration with Panels?