Thx for the nice module. Works fine.
Is it possible to include more fields from the view that selects the content?

Been reading about hooks, is this the way to go?
If so, is there any documentation or are there examples?

Ideal would be that the fields selected in the view all appear in the xml.

Options for content are then unlimited.

Comments

mclaren’s picture

I have modified sunmailer-xml.inc like the one shown below. It now brings all view/CCK teasers in 'preview' mode. But, when I actually send the newsletter, no teasers appears in emails. something wrong with my code? Anybody?

/**
182	 * Generates the XML for a content piece.
183	 */
184	function sunmailer_xml_content(&$dom, $node_fields, $account) {
 +        global $base_root;
185	  // Retrieve the content information.
186	  $node = $node_fields['node'];
187	  $title = filter_xss($node->title);
188	  $link = url("node/{$node->nid}", array('absolute' => TRUE));
189	  if ($node->uid) {
190	    $author = filter_xss($node->name);
191	    $authorlink = url("user/{$node->uid}", array('absolute' => TRUE));
192	  }
193	  $date = format_date($node->created);
+         $teaser = node_view($node, TRUE);
194	  // Add basic node information to the content XML.
195	  $content_node = $dom->createElement('content');
196	  _sunmailer_append_cdata_child($dom, $content_node, 'title', $title);
197	  _sunmailer_append_cdata_child($dom, $content_node, 'link', $link);
198	  if ($author) {
199	    _sunmailer_append_cdata_child($dom, $content_node, 'author', $author);
200	    _sunmailer_append_cdata_child($dom, $content_node, 'authorlink', $authorlink);
201	  }
202	  _sunmailer_append_cdata_child($dom, $content_node, 'date', $date);
+	  _sunmailer_append_cdata_child($dom, $content_node, 'teaser', $teaser);
204	  // Add additional fields to the content XML.
205	  foreach ($node_fields as $name => $field) {
206	    if ($name == 'node') {
207	      continue;
208	    }
209	    _sunmailer_append_cdata_child($dom, $content_node, $name, $field);
210	  }
211	  // Allow developers to alter the content XML.
212	  module_invoke_all('sunmailer_xml_content_alter', $content_node, $dom, $node, $account);
213	  return $content_node;
214	}

Mike Wacker’s picture

Status: Active » Closed (works as designed)

If you have any fields in your view, they will automatically be included in the XML. Check out the XML preview.

However, the XSL files that come with SunMailer only support the basic information for each node. Each node type is different, so the XSL can only use information common to each node type. It can't possibly predict how all current and future node types will be organized. Thus, you'll have to modify the XSL if you want to leverage content specific to a certain node type.

So long as you can expose whatever you need in the Views fields, you shouldn't need to change the code - you only need to change the XSL.