I am wondering how to create a block to display all of the users terms on the users page (../user). (i.e Take it out of the default profile and move it into a sidebar)?

Comments

yeputons’s picture

StatusFileSize
new3.62 KB

Patch is attached. If you don't know how to apply it, follow this instruction:

  1. Open patch with any text editor
  2. For each "block" in this file found it in the sources
  3. Remove all lines marked with "-" and add all lines marked with "+". Non-marked lines are only reference points

Please report here about results

yeputons’s picture

Status: Active » Needs review
joachim’s picture

Status: Needs review » Needs work

I'm not sure what this patch does... does it show the user their own terms? I'm not entirely sure what the point of that is...

Anyway, here's a review of the code:

+++ user_terms.module	20 Jul 2010 08:40:22 -0000
@@ -68,6 +68,11 @@ function user_terms_user($op, &$edit, &$
+        $config['hide_in_profile'] = FALSE;

We don't need this -- just use block visibility settings.

+++ user_terms.module	20 Jul 2010 08:40:22 -0000
@@ -89,6 +94,69 @@ function user_terms_user($op, &$edit, &$
+    unset($dest[0]); $dest = urldecode(implode("=", $dest));

And for future reference, the way to test where you are is to use arg().

+++ user_terms.module	20 Jul 2010 08:40:22 -0000
@@ -68,6 +68,11 @@ function user_terms_user($op, &$edit, &$
+      if (!isset($config['hide_in_profile'])) {

No need for this. Just use block admin to set block visibility.

+++ user_terms.module	20 Jul 2010 08:40:22 -0000
@@ -89,6 +94,69 @@ function user_terms_user($op, &$edit, &$
+        t('For example: %example regex accepts pages like user/%uid and user/%uid/*',
...
+    $dest = explode("=", drupal_get_destination());
+    unset($dest[0]); $dest = urldecode(implode("=", $dest));

For future reference, the correct way to test where you are is with arg(). So arg(1) gives you the UID straight away.

Powered by Dreditor.

yeputons’s picture

Status: Needs work » Needs review

It shows terms of any user. UID is getting from current page address (via PHP regex). You can show this block not only at the user/* - it can be shown at Views' page ("publications of this author") like node/by-author/*.

  1. This option only displays/hides "user terms" profile category.
  2. arg() is not applicable here, because we don't know anything about a page where we are.
  3. Look #1
  4. Look #2
joachim’s picture

Hmm.

Thinking about this some more (and I'm sorry I'm dashing in and out, but super busy this week with other stuff), this could be better done with Views:

- you can build a view of terms with UID argument.
- Views has default argument plugins which can extract the uid from /user/*
- for the node/by-author/uid case I can't remember if you can tell a block's default argument plugin to look in a particular argument position. But if not, it's only a patch away and would be a great addition to Views.

pixelsweatshop’s picture

Thanks for your input so far. i have gotten as far as building the view with the UID argument, but I can't get the node/by/author. Ideas?

pixelsweatshop’s picture

Is this something that may work? http://geeksandgod.com/tutorials/computers/cms/drupal/limit-views-create...

I am not quite certain, but i think the user info is not a node and therefore does not have an author, no?

joachim’s picture

You'll need to code a new subclass of views_plugin_argument_default that provides a default argument from a specific URL piece.

I suggest you submit this as a patch to Views.

joachim’s picture

Status: Needs review » Needs work

Setting to needs work.

I'll consider a patch that creates a default view that provides a block, but I don't consider this a priority for the module.