I have been trying to create a list of taxonomy subscriptions as a block in subscriptions_taxonomy.module -

/**
 * Implementation of hook_block().
 *
 * 
 *
 * @ingroup hooks
 */
function subscriptions_taxonomy_block($op = 'list', $delta = 0) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Subscriptions Taxa');
      return $blocks;
	  case 'view':
	  global $user;
				$vocabularies = function_exists('taxonomy_help') ? taxonomy_get_vocabularies() : array();
			  	$omits = variable_get('subscriptions_omitted_taxa', array());
			  	foreach ($omits as $omit) {
				unset($vocabularies[$omit]);
			  	}
				$account = $user;
				
				        return array(
          'subject' => t('Subscriptions'),
          'content' => drupal_get_form('subscriptions_taxonomy_taxa_form', $vocabularies, $account, $form)
        );
  }
}

This is fine within user/subscriptions, but I can't get it to fire on say, a usernode (white screen and HTML header is all i get). Am I missing something simple?

Thanks

Comments

salvis’s picture

Category: feature » support
Priority: Normal » Minor

Try removing code until it stops crashing and then very carefully build on what you have. Compare with subscriptions_ui_block().

salvis’s picture

Status: Active » Closed (fixed)

Feel free to reopen and post where you stand.

gregarios’s picture

Title: Creating Subscriptions block - for use on other pages » Creating Subscriptions block for use on Taxonomy Term pages
Version: 5.x-2.0-beta12 » 6.x-1.x-dev
Priority: Minor » Normal
Status: Closed (fixed) » Active

Tried to get this working in the D6 version using this block.

I get this error in the logs along with the WSOD:
PHP Fatal error: Call to undefined function subscriptions_form_helper() in /sites/all/modules/subscriptions/subscriptions_taxonomy.module on line XXX
(The line number is wrong because I added the hook_block code to the file.)

If you change $vocabularies to something like 'dummytext' in the drupal_get_form line then the block will successfully show up, but only with a block subject and no block body contents. No PHP errors reported, but no subscriber form.

I would be very interested to get this working. ( Even more than the template issue ;-) )

salvis’s picture

Seems like you're missing an include for the file where the function is located.

gregarios’s picture

Thanks Salvis! That did it. I have the user's taxonomy categories listing (just like the "taxa" subdirectory in their profile page) in a block on each Taxonomy term page now.

All it needs now is a small filter to only show the one taxonomy category checkbox that corresponds to the page I'm viewing.

Have any quick genius how that should be incorporated into this function?

I have some code that shows how to get the term ID in the theme files, but not sure how it would incorporate here, nor how to use it as a filter:

$url_request_uri = check_plain(request_uri());
$section = explode("/", $url_request_uri);
$currenttid = arg(2);

function getTermsName($currenttid){
  $taxterms =  taxonomy_get_term($currenttid);
  $termsname = $taxterms->name;
  return $termsname;
}

print getTermsName($currenttid); //TERM NAME
print check_plain($currenttid); //TERM ID

Any ideas?

Oh... here is what I have that works so far:

/**
* Implementation of hook_block().
*
* Define the Subscriptions Interface block for taxonomy pages (depending on the Display Settings).
*
* @ingroup hooks
*/
function subscriptions_taxonomy_block($op = 'list', $delta = 0) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Subscriptions Taxa');
      $blocks[0]['cache'] = BLOCK_CACHE_PER_PAGE;
      $blocks[0]['region'] = 'content';
    return $blocks;
    case 'view':
      global $user;
      $vocabularies = function_exists('taxonomy_help') ? taxonomy_get_vocabularies() : array();
      $omits = variable_get('subscriptions_omitted_taxa', array());
      foreach ($omits as $omit) {
        unset($vocabularies[$omit]);
      }

      // get current tid
      if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && is_null(arg(3))) {
        $termid = arg(2);
      }

      // only show block on taxonomy term pages
      if (!$termid) {
        return $block;
      }

      // get parent tid and parent term name (if any)
      $parents = taxonomy_get_parents_all($termid);
      $parent_tid = max(array_keys($parents)); 
      $parent_term_name = $parents[$parent_tid]->name;

      // get current term name from current tid
      $taxterms =  taxonomy_get_term($termid);
      $current_term_name = $taxterms->name;

      // NEED SOME CODE HERE TO REMOVE ALL ARRAY ITEMS FROM $vocabulary LEAVING ONLY THE CURRENT AND PARENT TERMS

      $account = $user;
      include_once drupal_get_path('module', 'subscriptions') .'/subscriptions.admin.inc';
    return array(
      'subject' => t('Subscriptions'),
      'content' => drupal_get_form('subscriptions_taxonomy_taxa_form', $vocabularies, $account, $form)
    );
  }
}
salvis’s picture

You'll have to massage the form that you get from drupal_get_form().

dpm() what you get so you see its structure, then add code to loop over the terms and unset() those that you don't want.

jaysonjaynes’s picture

Version: 6.x-1.x-dev » 7.x-1.0

Hey there, I'm completely new to Drupal, and don't really know PHP. Is there a way of doing this in D7? What I'm really looking to do is to have a "Subscribe to this term" checkbox like the "Subscribe to this page". Any ideas how I could do that? I appreciate any help...

karing’s picture

Version: 7.x-1.0 » 6.x-1.x-dev

If you've enabled Taxonomy Subscriptions module and
- if eg you were to have a site with nodes about all your website projects
- if you were on one of these nodes and it had Taxonomy Term "Drupal project"
- then you would find a Checkbox to Subscribe 'To content in Drupal project' in the Subscribe field set (by default at the bottom of the node).

Hope that helps.

PS - This thread is about blocks in D6 - if you're going to reply please open a new issue and move your post there. That helps us to keep things organized. Thanks,

gregarios’s picture

@KarinG: I believe this thread is about creating a block with links to subscribe/unsubscribe to taxonomy terms from taxonomy term pages, not from nodes.

karing’s picture

@gregarios: yep - that was my shorthand version. @Jayson's message didn't seem to fit in this queue.

salvis’s picture

Status: Active » Closed (fixed)

I think this thread should have been closed in March.

gregarios’s picture

Status: Closed (fixed) » Closed (won't fix)

You're right. It was closed, but it certainly wasn't fixed. ;-)

salvis’s picture

I consider a support request to be fixed when the OP stops posting.

jaysonjaynes’s picture

What I'm asking for is a "subscribe to" on a taxonomy page, not a node page. This isn't the right page? Is that cause I'm using D7? I'll create a new thread, but it seemed to fit this one. I'm new to forums, so thank you for helping me out. I really appreciate it!

salvis’s picture

@Jayson Jaynes:

The short answer is: no, we don't have that.

The long answer is: the situation in D7 is unchanged from D6. Creating a block is a possible approach (but you'll also need a [Save] button, of course). Ask gregarios why it didn't work for him.

I would probably implement this as a subscribe/unsubscribe link. This would require a hook_form_alter(). You can create a new feature request, maybe someone will pick it up...

raulmuroc’s picture

Why this won't fix? Is really an interesting feature and even necessary.

Is a little in-congruent having a Taxonomy subscriptions way that you have to enter into my account > list of taxonomies available to subscribe and choose with checkboxes. <--- Computer guy mentality!

The mentality of end-user is more of " ok, i go at that term page to visit and see it, for example #NewYork and look, i like it really a lot and wish to subscribe to have the new, i will subscribe in it... wait a minute: where the f*** is a subscribe button????"

That's the user-mentality and that's what we net to cover so yes, is needed a SUBSCRIBE link at the term page itself.

This issue should be turn to Active or at least wrihte a reference link to other issue which actually deals with this topic.

raulmuroc’s picture

Issue summary: View changes
Status: Closed (won't fix) » Closed (duplicate)

Duplicate of: Cannot subscribe to taxonomy terms on term page

Fortunately, cuz would be a pity if we don't work to solve this point :-)