PostHere patches

patches based on CVS as of 2004 July 23

by Andy Goldberg  drupaldev@andy2.com  2004 July 23

Please e-mail me if you find this useful! (or have suggestions, complaints :( or questions)

I don't know the difference between the open-source licenses, just say this is under the same license as Drupal itself.  

---------------------------------------

What does it do?
  When viewing a single taxonomy term, adds a "post here" link that initiates the 'create content' procedure, but hides the taxonomy selection on the form.  Instead, the post is added automatically to the term (category) the user was viewing.

Why do I need this?
  This makes adding content much easier, especially for novice users.  Especially with complicated vocabularies/taxonomies, users can get confused or make mistakes regarding which term they intend to add content to.  With "PostHere", they can immediately add content to the category they were viewing.

  To compare, imagine if after you clicked "add a comment" you then were presented with a menu of all the posts and you are expected to select the correct one.  Or, imagine when reading a discussion forum, clicking "new topic", and you are presented with all topics and you must select the one you were just reading.  It's very possible in both cases that you would forget, or possibly make a mistake.  With novice users, that possibility is magnified.

Does it change or replace any existing functionality?
  No.  Adding a "Post Here" link is voluntary.  With or without it, the existing 'create content' functionality is exactly the same.

Why is this a patch and not a module?
  Unfortunately, the functionality requires changes to a few core modules.  Fortunately, as you can see, these changes are small, so if you are reading this while PostHere is not in the Drupal core, it is not very difficult to make all the required changes.

Basically, how does it work?
  1. When a module is called through a URL, if that module is going to expose one taxonomy term, it passes along an extra parameter to theme("page", ...) containing that single term id.  Any module that exposes taxonomies can be modified easily.  The obvious one is "taxonomy", and I have also modified (2 lines) "taxonomy_menu".
  2. The theme is actually responsible for creating a "PostHere" link on the page it renders.  I use XTemplate, so I have modified that theme in this package.  Other themes should be easy to modify.  Since you have sent the term id to [themename]_page, it uses that parameter to create a link to "node/posthere/[term id]"
  3. When the user clicks the link, the node module takes over.  The user is presented with the list of node types, filtered by only the types that are allowed by the vocabulary in question.
  4. When the user chooses the content type, he/she gets the same form to add content as usual, except that the options to choose a taxonomy are removed.  Instead, that information is passed with a hidden 'input' field.  When the user submits the new post, it is automatically added to the correct taxonomy!

Does this eliminate an administrator's ability to categorize posts?
  No.  Anyone can still use the normal 'create content' link and the taxonomy select options will still appear on the new node form.  Additionally, those options are always still shown when editing a link (admin or regular user).

What else need to be done?
  - Since the "Post Here" link is actually rendered by the theme, all themes must be patched even if this gets into the core.  Fortunately, the modifications are very minor.  
  - The current version does not handle cases where you have a "required" vocabulary.  But in this case, you probably would not want this functionality because you would be "posting here" to a category that might not be in the "required" vocabulary.