PostHere patches

patches based on CVS as of 2004 July 23

by Andy Goldberg drupaldev@andy2.com 2004 July 23

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

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.

CommentFileSizeAuthor
posthere.zip7.17 KBandynyc

Comments

dries’s picture

I'm not going to apply this patch until this has been thumbed up (or requested) by other users/developers.

You might want to use tabs for these local 'post here' actions.

When documenting a function, please use PHPDoc-style comments.

Some of the code/paramaters are awkward (eg. $boo_validtypefound).

jonbob’s picture

It seems to me like this is an example of something that would be best handled by the proposed "global context" construction.

One of many references on the topic:
http://lists.drupal.org/archives/drupal-devel/2003-11/msg00527.html

andynyc’s picture

I appreciate and respect your opinion, but I'd like to defend my patch:

I'm not going to apply this patch until this has been thumbed up (or requested) by other users/developers.
There were some people who thought this was a good idea when I originally proposed it: see here. I think more people would appreciate it if they saw it work... it's the kind of thing that seems obvious once it exists.

You might want to use tabs for these local 'post here' actions.
This is definitely an idea, however I have not used the CVS version with these tabs... I would definitely look into it when CVS is closer to completion. My patch works on 4.4.1, and currently the theme actually inserts the link, so as it stands, it is flexible.

When documenting a function, please use PHPDoc-style comments.
At this stage, pre-patch, my comments are intended to allow you guys, the patch reviewers, to follow my changes as closely as possible. My initials are in there only because I need a way internally to keep track of my modifications. If the code was to be approved for the core, I would certainly create better comments.

Some of the code/paramaters are awkward (eg. $boo_validtypefound).
Since this is my first patch, it may not be 100% consistent. The variable you mention is a boolean value (referenced one time), so I added boo_ to the name. However, there are very few (zero?) other times when I use this practice. I deviated from my personal coding style to try to be consistent with the core. You guys run this show, so I'm happy to hear your suggestions for improvements in this area.

My comments:

As I mentioned in the notes to my patch, adding it to the core doesn't change any functionality whatsoever. It only makes new functionality available. But it can only be utilized if the "Post Here" link is implemented by the theme (fortunately, a minor edit), and by the module which exposes the taxonomy view (another minor change, 2 lines?). Once it is in the core, it is like an API, modules could be developed to take further advantage of it (for example a graphical site map with a 'posthere' link at each taxonomy term)

This patch does not use much additional system resources. All parameters are passed through the URL. In fact, when used, it should reduce system load slightly, because it replaces recursive database lookups (required to create the taxonomy drop-down list) with a single query. (These may be cached, if so, then this would be incorrect)

PostHere may not look very important to a blogger or someone running a small site, which may only contain a dozen categories, or a site where experienced users only, who fully understand the taxonomy structure, are adding content.

Imagine a corporate site which may have taxonomy terms for dozens of departments in multiple cities. Or for a university site, with a taxonomy for every section of every class, plus groups, clubs, faculty, etc. It is not hard to imagine having hundreds of taxonomy terms in these situations. And 99% of the users won't have any idea about your site structure. Being able to just post directly to a category, instead of choosing from an incredibly long list, is essential.

The comments module lets you add a comment directly to the post you were reading. The forum module lets you add a new topic directly to the section you were reading. Users expect the ability to add a story to the category they were reading, not have to select it from a huge list. As developers, it is difficult "forget what we know" and to put ourselves in the shoes of novice users, but we have to, if we are to be effective.

Drupal is receiving a lot of interest right now from the first kind of site developers I mentioned... bloggers and small-site operators, coming over from MT and others. So the majority of feature requests have been for things these users want. Large-scale site developers are in the minority. But we are here, because Drupal has the power to handle these sites. MT and Blogger aren't even a consideration for us. But to fully realize the potential that Drupal has, it has to be as "friendly" to the needs of large-scale sites as to small ones. I truly believe that Drupal can get there, that is why I am using it and trying to improve it.

killes@www.drop.org’s picture

I might be mising something, but wouldn't it be possible to add the taxonomy term to add to as a GET variable? This variable could be parsed by a contrib module and the taxonomy terms could be pre-selected according to this. Granted, you could not hide the taxonomy selectors through this but this might be a advantage. The patch as it is changes quite a lot in core so its chances aren't that good, I guess.

andynyc’s picture

I might be mising something, but wouldn't it be possible to add the taxonomy term to add to as a GET variable?

That's exactly what this does. Instead of going to "node/add/story" , a new link directs you to "node/add/story/posthere/14" (with 14 as the taxonomy id), and then the taxonomy drop-down list is not rendered on the input form (a hidden input is rendered instead). It's all in the GET, no additional POST variables.

The patch as it is changes quite a lot in core so its chances aren't that good, I guess.

I don't think this is true. You could implement the changes in the core and see absolutely no difference, if you never added the "PostHere" feature to your theme or module. The extent of the changes to core modules are essentially just adding an optional parameter to some function calls.

killes@www.drop.org’s picture

So I understood at least part of the plan.

You could implement the changes in the core and see absolutely no difference, if you never added the "PostHere" feature to your theme or module. The extent of the changes to core modules are essentially just adding an optional parameter to some function calls.

You need to understand the Drupal development model: If we would have added every feature in the core that somebody wanted to have we would be *nuke II now. We are very aware of creeping featuritis and have the mantra to do everything as simple as possible but not simpler. I guess your patch will have to become a bit simpler still. :)

andynyc’s picture

Killes-

I do honestly appreciate you taking the time to consider this, and I respect the opinion of you and Dries, and the rest of the crew here. And I understand the problem of featur-itis. Believe me, if I could have implemented this as a totally separate module, I would have, however I don't think it is possible, at least not under the 4.4 version. As far as keeping things simple, I still think I have done that, the patch doesn't add any new functions/procedures, the most it does is require an extra, optional parameter on some (two?) calls.

I defer to you, since you have done an exceptional job so far. If you think it is too complex or intrusive, then it should not be in the core, no matter what I think.

However, I will re-iterate what I said earlier in this thread, that I believe Drupal has the power to do so much more than be a blog engine or tight community portal. It can run an entire school or corporate site, with hundreds of taxonomies. But it needs to be friendlier to novice users in these situations. Presenting a drop-down list with 200 or 400 taxonomy terms every time they post (or multiple drop-downs for multiple vocabularies), is not an acceptable situation. Anyway, thanks.

moshe weitzman’s picture

I much agree that that these small tweaks help novice users at minimal cost. perhaps this patch wasn't perfect, but the idea is right on. usability usually adds a fwew lines of "unnecessary" code. its ok, folks.

killes@www.drop.org’s picture

I also would like to see this patch applied. I just think it needs more work. For example, the "add child node" functionality for the book module first also needed a patch to node module but it turned out that was not neccessary.

andynyc’s picture

Wow... nice to see my idea revived from the dead :)

I understand the desire not to mess with core modules. I just don't see a way to prevent the rendering of the taxonomy selection input (actually, replacing it with a hidden input) without modifiying the core module.

But I am open to suggestions. Maybe 4.5 handles things like this differently?

coreb’s picture

Version: x.y.z » 6.x-dev

Moving out of the x.y.z queue into 6.x-dev.

mcreature’s picture

Is any one working on something like this for Drupal 5.0 - 6.0 dev, or possibly an all inclusive module?
I have been wondering why this has not been discussed in more detail, or delved into further for the last few years; it seams the next logical step towards simplifying Taxonomy usability.

birdmanx35’s picture

Just want to add my two cents:

This is definitely a case of feature paranoia. I think this is a great idea, especially for sites with hundreds of terms. +1

pasqualle’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Needs work
MichaelCole’s picture

Status: Needs work » Closed (won't fix)

Great idea! This would make a great contrib module. Marking won't fix for d7 core, but hope to see the module.