I've been searching around but couldn't find much on this.
I'm interested in converting the 'blog this' function, which allows users with access to blog.module to create new nodes from aggregator links, to a more generalised function. There seems like a few possibilities for it though, and I'm not a coder, so thought it'd be worth posting this to keep track of ideas and see if anyone else has done or is trying to do the same thing:
Most of the relevant code is here in blog.module
/**
* Implementation of hook_form().
*/
function blog_form(&$node) {
global $nid;
$iid = $_GET['iid'];
if (empty($node->body)) {
/*
** If the user clicked a "blog it" link, we load the data from the
** database and quote it in the blog:
*/
if ($nid && $blog = node_load($nid)) {
$node->body = '<em>'. $blog->body .'</em> ['. l($blog->name, "node/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
// Note: $item->description has been validated on aggregation.
$node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
}
}
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
$form['body_filter']['filter'] = filter_form($node->format);
return $form;
}
and this bit in aggregator which generates the link
if ($user->uid && module_exist('blog') && user_access('edit own blog')) {
if ($image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
$output .= '<div class="icon">'. l($image, 'node/add/blog', array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), "iid=$item->iid", NULL, FALSE, TRUE) .'</div>';
}
}
The things I'd like to be able to do are this:
1. "discuss this article" link on different drupal node types, which create a forum post with a link to the article and/or the teaser. We've got busy forums and would rather keep comments there rather than enabling comments on nodes everywhere else which can be hard to keep track of.
2. Converting aggregator items into news nodes - I understand the "aggregator 2" module does this but haven't tried that yet
For number 1, it seems like it'd be easy enough to hack that blog.module code and add it to forum.module, then insert the code into other node displays on the theme level with maybe with a .tpl.php?
I think what'd be a bit more tidy would be to add a link into the service links module:
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/service_links...
that makes drupal posts using the blog_form code. That'd give a lot of flexibility with display etc.
Or maybe build a new module from scratch that adds this functionality. The main advantage I can see is that whereas a forum node is started with the intention of a discussion, news items (or for us, on-line library etc. entries) aren't - so when it's 2, 3, 5 years old you'd have a lot of comments not necessarily related to each other, this'd fix that.
Comments
Good idea!
Please post if anything comes of it. I'm interested in the ability to do something similar for external web sites, too. (The Wordpress "Blog This" concept.)
~ben http://bemweb.com/contact/
benjamin, Agaric
Making it generic means its own module? Some thoughts.
- the quote module quotes text from a node into a new comment on that node. That code may be relevant too.
- What I would like to be able to do is click on "quote", then receive a list of content types to choose from, then get the "add" page of that content type with the text quoted in the body text area. On that page it should also let me select to quote it into a new comment to the original node, as the quote module does currently.
Possible to support CCK/Flexinode?
What when we create new content types with CCK or Flexinode? Is it possible to make such a function generic so that it builds the list of selectable content types dynamically? Is it possible to detect/locate the text areas created with CCK/Flexinode so that the module will know where to place the quoted text? I guess CCK/Flexinode compatibility should not be a priority in the first version of this, which I believe needs to be a module of its own.
Then a feature that will obviously be a greater challenge, further down this road?:
(also performance-wise, and is possibly related to another effort of splitting comment threads into new/own nodes):
- possibility to drill down on existing nodes, maybe only among books: choose an existing node onto which to quote the text as a new comment.
.
--
( Evaluating the long-term route for Drupal 7.x via BackdropCMS at https://www.CMX.zone )
- the quote module quotes
That sounds ideal - probably with an admin option to restrict node types you can quote into.
Since CCK is going to be core in the next release, I think it'd have to support that. Certainly the page/story/forum/book/blog implementations in flexinode. Then for custome node types, maybe a form to add the functionality in with a place to specifiy the field it'll quote into? I'm not a coder at all, so these are all just ideas at this stage.
One possible idea - combine some of the quote module functionality with "comment mover" - it'd have to dynamically create the content (already done with quote, but we're disabling comments on the nodes this applies to right?) then within the same process prune it from the original node and graft to a new node.
Hoorah! I've been looking
Hoorah! I've been looking to configure this for ages, also pretty much as a non-coder. I set up drupals for class scenarios, where students have got to comment on posted work, but where the prof wants each student's posts to be collected in one place (e.g., blog) for easier grading. Would be great to extend this aggregator functionality. In particular I'd like to see it extended for images, in which a thumbnail is the resultant "quote."
Not necessarily - I could see the use for both. Discussion on the node itself doesn't preclude someone grabbing a quote of the node for their own blog, or vice versa. I'd suggest not limiting that.
Sounds like two different permissions per content type: quote into (whether this content type appears in in a list when hitting the quote button on any node) and quote out of (whether the list appears at all)?
Is there a name that might encompass this functionality better than "quote" or "blogit"?
custom module...
You should implement this as a custom module- altering the core modules means you are locking yourself out of an easy upgrade path when the next version of Drupal comes out.
I think this could actually be a very simple module- about as much code as above. The key parts would be implementation of hook_link and hook_form_alter. I'd use a custom query string in hook_link as above in the aggregator module (for example, "discuss=$node->nid") and then in hook_form_alter you can look for this query strong ($_GET['discuss']) and then wrap the node body (or just the teaser) in blockquote tags (after running check_markup) and make it the default body of the forum topic with a link back to the original node.
Obviously, some basic validation checks are needed to insure you're not setting yourself up for SQL injection, etc. See: http://drupal.org/node/62304
See here for how you can use hook_form_alter to change the default value of the body of a forum topic: http://drupal.org/node/70906
If you get this working (and don't want to make it a contrib module), consider posting it under: http://drupal.org/node/70903
---
Work: BioRAFT
Interested
Is anyone working on this? ...It would be a great module.
I think something like what The Onion uses would be perfect.
See an example (Blog This) here: http://www.theonion.com/content/node/54916
That's just a javascript, not a module.
The theonion.com example is for copying the URL/title to paste on some other external blog. It probably works without any special module functions.
What we need a module to do is to blog that info into a new node on the same drupal site, not by copy/paste on the user part, simply by creating a new node and copying that information along.
The Javascript example can of course be a separate option, letting people blog it outside instead. But that does not really require or have much to do with a module.
.
--
( Evaluating the long-term route for Drupal 7.x via BackdropCMS at https://www.CMX.zone )
Blog any node
I'm relatively new to drupal, but this seemed like an excellent feature for a community driven site.
In the same way that the "blog it" feature passes in the aggregator item id, a "blog this node" feature could pass in a node id. Something like this:
http://www.example.com/node/add/blog?btid=123
Then we'd add this snippet of code directly after the if($iid ...) block shown above:
This seems to work well for me? Any thoughts or concerns?
Thanks
Looks good
- can you post it in "module form" so it can be tested?
.
--
( Evaluating the long-term route for Drupal 7.x via BackdropCMS at https://www.CMX.zone )