Add path user/{uid}/content to get a listing of one user's nodes

robertDouglass - May 6, 2005 - 15:23
Project:Drupal
Version:4.7.x-dev
Component:base system
Category:feature request
Priority:normal
Assigned:robertDouglass
Status:closed
Description

This creates a new path user/{uid}/content which functions just like node, except it returns only one user's nodes. Minimally intrusive. Hopefully useful. Open to alternate suggestions on the path (should it be a path in the node module?) and the page title (currently "user content").

AttachmentSizeStatusTest resultOperations
usernodes.patch.txt2.27 KBIgnoredNoneNone

#1

robertDouglass - May 6, 2005 - 15:34

Hmmm - not good. If the user doesn't have any nodes the default text for a new site ("Welcome to your new Drupal-powered website. This message ...") pops up.

Setting to won't fix until I come up with a better solution.

#2

Dries - May 6, 2005 - 15:35

Where is it linked from? How does it look like? How does this interact with the tracker?

Seen this: http://flickr.com/photos/factoryjoe/12517114/?

#3

robertDouglass - May 6, 2005 - 16:14

Ok, this is better. This adds a new function, user_nodes, and two new paths:
1) user/{uid}/content
2) user/{uid}/content/feed

The first works and looks just like the current q=node path, the second just like node/feed, both only showing the published content of the user {uid}.

AttachmentSizeStatusTest resultOperations
usernodes.patch2.txt2.26 KBIgnoredNoneNone

#4

robertDouglass - May 6, 2005 - 16:15

Dries, the tracker module shows a tabular view of basically the same content. That's useful for tracking, but not for having a "front page" view of one user's content. Tracker also doesn't offer a user feed, afaik.

#5

adrian - May 6, 2005 - 16:31

How does this differ from blog ?

In that any type of content is shown? Isn't the idea to turn blog into an extension of any node (kind of like the new events) ?

#6

robertDouglass - May 6, 2005 - 16:37

Yes, you're right, in which case it would make more sense to have this method in user than rely on blog/{uid}. The blog=anynode solution makes this functionality dependent on the blog module -my suggestion isn't dependent on any other module. It lists all of a user's content. Seems like the right place for a method like this is in the user.module, not the blog module.

#7

Dries - May 6, 2005 - 18:10

There are at least 4 formats:

  1. The teaser format (titles + author + teasers)
  2. The tracker format (titles + author)
  3. The block format (titles only)
  4. The RSS format

There are at least 3 filter mechanisms:

  1. Filter by node type
  2. Filter by category
  3. Filter by user

So how about this format:

http://example.com/$format/$filter/

Examples:

teaser -- shows all posts in teaser-format
teaser/type/blog -- shows all blogs in teaser-format
teaser/user/<uid> -- shows all posts from user <uid>
teaser/category/<tid> -- show all posts in category <tid> in teaser-format
...
track -- show all posts in tracker-format
track/type/blog -- show all blogs in tracker-format
track/category/<tid> -- show all posts in category <tid> in tracker-format
...
rss/category/<tid> -- show all posts in category <tids> in rss format
...

or even
rss/type/blog,forum/category/1+2/user/1,10,100

What we need:

  1. A function that takes a filter URI as input, and that returns a valid SQL query
  2. A function that takes a valid SQL query and a format as input, and that returns a chunk of HTML

Example usage:

  1. format_nodes(query_nodes('/type/blog,forum/category/1+2/user/1,10,100'), 'rss')
  2. Want to create a block with a user's last forum topics? Create a PHP block with the following snippet:
    print format_nodes(query_nodes('type/forum/user/$user->uid'), 'titles');

NOTE: we might have to refine the URL schema and the API but this would come a long way.

#8

moshe weitzman - May 7, 2005 - 00:51

nice suggestion, dries ... i suggest that the best name for the 'tracker' format is 'table'.

#9

Steven - May 7, 2005 - 04:06

I really like this idea. The current taxonomy URLs are already a bit like this.

Taxonomy URLs have 2 parameters though, one of which is optional. By using default values, we can take care of this at the moment, but I'm sure how this would work with the current scheme proposed by Dries.

It also fits perfectly with what I was thinking of implementing for the admin/node screen: right now the user's refining filters are stored in the session. It would be nicer if they were stored in the URL (e.g. admin/node/type/blog), that way they can be bookmarked and aliased.

#10

Bèr Kessels - May 7, 2005 - 13:59

whats wrong with userposts.module. i does what you want, except for the tab/localtask thing. I am willing to commit that patch though.

#11

chx - May 7, 2005 - 21:42

As Dries said "a function that takes a filter URI as input, and that returns a valid SQL query":

http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/chx/urlfilter...

It's actually two functions but I hope that's OK...

#12

Steven - May 25, 2005 - 23:05

We seem to have a bit of a naming conflict here... filters for filtering text, or filters as WHERE clauses in queries.

Can someone suggest a better word for the second to avoid confusing?

#13

moshe weitzman - May 26, 2005 - 01:36

"conditions"

#14

Crell - December 28, 2005 - 23:59

Well the patch in #3 still applies cleanly, amazingly given its age. :-) Is that patch still being considered, though? If so, it applies cleanly but didn't seem to have any effect. If not, this should probably be refiled as active.

#15

robertDouglass - December 29, 2005 - 09:18

I refiled as "patch (code needs work)". I don't think this is being considered for core.

#16

Bèr Kessels - December 29, 2005 - 13:35

Userposts.module would be a very good candidate for this.

#17

Jaza - January 17, 2007 - 03:54
Version:x.y.z» 4.7.x-dev
Status:needs work» closed

I don't think that this is needed anymore, now that we have views. Views can do what this patch does, as well as pretty much every other filtering combination suggested in this thread.

Closing.

 
 

Drupal is a registered trademark of Dries Buytaert.