I want to show a table (using views) displaying a list of the last node (latest pub date) for each content type.
Any ideas?
Use a View and code to embed that View for each content type.
To get the same View as what I created, import the View I've pasted here: http://pastebin.com/2xQx7BPs
Instead of having anything hardcoded, you can achieve this as follows:
Paste this:
<?php
$content_types = node_type_get_names(); // get all content types
$ct_machine_names = array_keys($content_types); // we just need machine names
foreach ($ct_machine_names as $ct_name){ // loop through, adding them as an argument to the View
echo views_embed_view('latest_node_by_type', 'block', $ct_name);
}
?>
There are a few ways to achieve this instead of using the "PHP filter". Using a custom block in your own module isn't difficult. My favorite resource that explains this is located here: http://kahthong.com/2013/06/create-your-own-custom-drupal-block-programmatically
Follow the directions, and replace the last block with something like this:
<?php
function _YOUR_MODULE_BLOCK_ABC_CONTENT() {
$output = '';
$content_types = node_type_get_names(); // get all content types
$ct_machine_names = array_keys($content_types); // we just need machine names
foreach ($ct_machine_names as $ct_name){ // loop through, adding them as an argument to the View
$output .= views_embed_view('latest_node_by_type', 'block', $ct_name) . '<br/>';
}
return $output;
}
?>
Just create a view, add the "Node: Title" Field and sort your nodes by date added.
1.) In your views Fields include content type
2.) Then set Format as Table and group them by content type
3.) Sort them by date desc
4.) on Pager select "Display a specified number of items" and enter 1 for it to show only 1 link for the node
That should be it..
You can achieve this by using aggregation. In the views edit screen (considering you have already configured your content type filters and fields), look under advanced (right side). Near the bottom of the list locate "aggregation:No", set it to yes. Go back to your fields and change aggregation settings according to your needs.
Use attachments. Create a view display that shows only 1 of a certain content type. Create 2 more attachment displays, using the same settings but change the content type on each one to whatever you need, then attach those to the original display.