The attached patch adds a setting to the blogapi allowing site admins to choose the node type that blogapi entries will go to. This will be useful when wishing to do regular story (as opposed to blog-type) entry posting through the api.

questions to Nedjo Rogers nedjo@gworks.ca

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

I'd like this functionality too. But this patch may cause moe harm than good. If user chooses story or blog, the patch works. If he chooses book, or recipe or poll, etc., he will get a validation error. Thes node types require more information.

nedjo’s picture

Thanks for noting this; I'd failed to test with other node types. I've modified the patch to limit the choice to either "story" or "blog".

killes@www.drop.org’s picture

Doesn't apply anymore.

nedjo’s picture

Here is an updated patch. Now enables three choices: blog, page, and story.

Dries’s picture

I'm not going to commit this unless there is more demand for it.

nedjo’s picture

This functionality has been requested here (Posts made by w.Bloggar seem to be an entry other than "Story," which is what I want. I don't see any way to make w.Blogger post to this node type.) and here (they automatically post "personal blog entry" node types, I'd want them to post "story" nodes).

My judgement is that blogapi could readily be used considerably beyond the limited blog application. This small change would make the highly developed blogapi into a tool for general site posting rather than restricting it to what is, for many sites, a little-used medium, the blog.

Anonymous’s picture

Here's another vote for extending the blogapi to allow posting stories and other node types!

This would be a great addition.

Robert Castelo’s picture

This would be really useful for Drupal sites I've set up for companies - where employees enter content into a taxonomy created by me and the (client) project manager.

Most employees will be able to use a point and click desktop application much better than a Webpage interface with clunky Javascript controls (none of them know HTML).

Extending the blogapi to other node types would add considerable value to Drupal for business use.

moshe weitzman’s picture

+1 for the functionality. but there is a problem with the patch. it hard codes permission names from 3 different modules. instead, use node_access('create', $type). that fragment was taken from the end of node_add()

teradome’s picture

An idea:

Since blogid is a string identifier according to the APIs, why not allow node types to be selected by using the name of the node type itself?

You could keep the checkbox list of available nodes in the blogapi settings page (blog option on by default), which would also list what blogid string you need to enter in your remote client to access it. This way you can add them in incrementally. Legacy support via the user's system # could be maintained, but "blog" as a blogid would become the preferred way of "editing own blog." (Obviously, you can't do more than your own, given the simplicity of the APIs.)

Even more hardcore would be to implement this into a hook, so other modules could add blogapi support (I'm thinking "quotes" for one). Since you would identify by the node type, there's no overlap.

walkah’s picture

Assigned: Unassigned » walkah

teradome : excellent idea! i like this approach... and it should work well within the (limited) framework of the apis... the only thing is that several editors present this as a list of your "blogs" which may make it a bit confusing. however, it would cram this much desired functionality into the existing framework.

let me play with it for a bit, and i'll prepare a patch.

garym@teledyn.com’s picture

+1 from me on this one, although my own needs need a more generic REST/webservices interface way beyond bloggerAPI. I'd love to see micro-content publishing gateways such that we could seamlessly post complex items to the site, for example, posting member calendar information directly from a cellphone into the events.module or a Firefox XPI that exports/merges personal bookmarks files into the weblinks.

chrismessina’s picture

+1 on this patch (or the functionality at least). Right now, MarsEdit can't use Drupal categories because of limitations in the XML-RPC API (according to brent @ ranchero.com). It sounds like this kind of general change would enable me to use MarsEdit (or any other blog editor )to its fullest potentional.

Oh, and excuse any technical errors with my assessment... I only half-way know what I'm talking about. :1

Chris

mike3k’s picture

I really want to see this feature. I have two story based Drupal sites and I'd like to be able to post from MarsEdit. I like the suggestion of using 'story' or 'node' as blog ID.

nedjo’s picture

Here is an updated patch partially addressing Moshe's suggestion to remove hard-coded module references. I've left in hard-coded references in the "edit own..." instance because the word needed is different from the module name (e.g., "stories" for the story module).

why not allow node types to be selected by using the name of the node type itself?

I don't fully understand the suggestion of using the node type as an id. The id is set (I'm thinking) by the server--but the client has to first make the posting. How would a client select which type to create?

Right now, MarsEdit can't use Drupal categories because of limitations in the XML-RPC API (according to brent @ ranchero.com). It sounds like this kind of general change would enable me to use MarsEdit (or any other blog editor )to its fullest potentional.

This patch won't I think do anything to address that issue. The new release candidate of w.bloggar also seems to fail to set categories (when used in Movable Type mode). Likely we need to update the handling of category requests.

Anonymous’s picture

I'm a MarsEdit user and would love to use it with Drupal. The XML/RPC features need to have more visibility, there are many who *would* use them if they would know they exist and how they work.

walkah’s picture

FileSize
3.99 KB

here's a patch that implements multiple node types using the (admittedly very clever) blogid hack.

basically, you will appear to have "separate blogs" for each node type that you can post to.

(yes moshe, posting will fail for recipies and events, etc)

you can maintain different taxonomy vocabularies for each node type - which will work.

For those having trouble with MarsEdit : try setting the "Software" to movabletype... it works for me with 1.0b12 . Brent has an old profile for drupal in there it seems - back when we only did blogger api.

Please give this patch a try and offer feedback.

thanks :)

nedjo’s picture

Thanks for the patch. I am mystified by it, but this may just reflect my ignorance. Could you explain how to use this from the client end (e.g., using w.bloggar). How/where does one indicate that a particular post is e.g. a "story"? Does this patch accomplish the primary desired aim of this issue--enabling the use of blogapi by sites that don't use blogs?

walkah’s picture

nedjo: essentially this patch follows teradome's suggestion to make use of the formerly unused 'blogid' parameter that exists as part of the APIs - specifically using that parameter to specify the node type to create. how *exactly* this is used on the client side is dependent on how the client handles the fact that the API allows for multiple blogs per user account. i don't have access to a windows machine at the moment, so I can't tell you specifically for w.bloggar, but i'll give you two examples from the mac world:

attached to this issue is a screenshot of ecto (http://ecto.kung-foo.tv/) which is my preferred app. as you can see on my "local test" account i have 3 "blogs" - blog,page and story. thus posting to the "story" blog creates a new story.

marsedit (http://ranchero.com/marsedit) does not automatically list all blogs for a user account, rather you must specify a single blog id for each account. so, you'd enter "blog" (for example)... where as that previously defaulted to your userid (and was unused).

does that make sense?

walkah’s picture

FileSize
48.3 KB

screenshot of how this patch looks in ecto attached for real this time :P

nedjo’s picture

Thanks for the explanation, I get it now. This approach has the clear advantage (over what I'd suggested) of enabling a user to select from various node types rather than a single server-designated one. But it depends on settings on the client. This means extra instructions to users, instructions that will vary by the client. More importantly, some clients won't support this functionality. For example, I don't find a way to specify multiple blogs per user with w.bloggar (a commonly used client for Windows users). So, while this is in my view definitely an improvement on the existing module, it doesn't fully meet the identified need.

I would therefore like to see this patch in combination with the changes I suggested. I.e., user can select which node type to post to (as per walkah patch), admin can set default type if no type designated by user (my patch). That way there is advanced functionality for clients that support it and a default solution for clients that don't.

Also, likely we should have an admin setting to limit the list generated by function _blogapi_get_node_types() to designated types. I hard-coded this to "blog", "page", and "story", but we could instead have a multiple select.

Thoughts?

Boris Mann’s picture

If you can't specify multiple blogs per user, the client is broken. Seriously -- it means it won't work with Blogger or Blogware, to name two I know of right of the bat that support multiple blogs per user. Reading through w.bloggar's site, it does support multiple blogs for Blogger. If someone on Windows could verify that it also works with James' patch, I think we're done.

As walkah recently posted on his blog, we need to try and get better APIs, rather than continually kloodging on both the client and server side because of the limitation of the API.

nedjo’s picture

Title: blogapi--Allow site admin to choose default node type » blogapi--Allow posting to multiple node types

Okay, I agree, this fully meets the need, apologies for my slowness, it's just taking me a bit to catch on. The only change needed to the patch I believe is to edit _blogapi_get_node_types() so that it will generate a limited list of node types (only those that blogapi will work with) so that users won't get errors. This could be hard-coded to "blog", "page", and "story" or could be a multi-select (a new setting) set by site admins. E.g., to blogapi_settings, add something like (I haven't tested this):

  foreach (node_list() as $type) {
    $node_types[$type] = node_invoke($type, 'node_name');
    if (in_array($type, array('blog', 'page', 'story')) {
      $defaults[] = $type;
    }
  }
  $output .= form_select(t('Blog types'), "blogapi_node_types", variable_get('blogapi_node_types', $defaults), $node_types, t('Select the content types for which you wish to enable blogging.'), 0, 1);

and change _blogapi_get_node_types() to:


function _blogapi_get_node_types() {
  global $user;
  $approved_types = variable_get('blogapi_node_types', array('blog', 'page', 'story'));
  $types = array();
  foreach (node_list() as $type) {
    if (node_access('create', $type) && in_array($type, $approved_types)) {
      $types[] = $type;
    }
  }

  return $types;
}

Dries’s picture

... and document this peculiar usage in the help/documenation?

teradome’s picture

man, i can't believe i'm just seeing this patch now... the tracker really needs an option to follow "issues" that you've replied to!

teradome’s picture

This. is. sweet. And just in time for my new workflow changes (blog=no comments, forum=comments desired)! Thank you walkah!

walkah’s picture

here's an updated patch that allows administers to control which node types can be posted via blogapi (as per nedjo's suggestion). also i've added some documentation about the 'unusual' usage.

please apply for 4.6 :)

Dries’s picture

Committed to HEAD.

Mark OConnor’s picture

Is there a .diff file to go from the 4.5.2 distribution blogapi.module ( v 1.33 2004/10/18 18:40:53 ) all the way to the current blogapi.module ( v 1.36? 31 Jan 2005 18:28:35 )? Or, do I need to find the all the versions referenced in the diffs/patch files, and apply each of them in sequence?

I do not appear to get some of the functions discussed earlier, no list of blog-page-story anywhere. I can make it work in MarsEdit with 2 accounts and setting the blog ID to 'blog' on one and 'page' on the other, but I don't see any where in the ecto user interface to set the blog ID.

Thanks

Anonymous’s picture