There are six different notifications (templates) for subscriptions:

subscriptions-digest
subscriptions-node-nid
subscriptions-node-tid
subscriptions-node-type-article
subscriptions-node-type-blog
subscriptions-node-type-page

Could I get an explanation of when each of these comes into play? I ask because I thought that if I "Subscribe to this page" (blog post, node/42) that I'd get the subscriptions-node-nid notification, but instead I got the subscriptions-node-type-blog notification -- which I thought I'd get if I subscribed "To Blog entry content."

Comments

salvis’s picture

Subscriptions tries to give you the appropriate template. Rather than using the generic -nid template, it selects -type-blog for blog posts, but it uses the comment settings of the -nid template (only the -nid template has comment settings).

mrtoner’s picture

If Subscriptions will use the appropriate -type-[content type] template whenever a node is subscribed to, why does the -nid template exist at all? If only for comments, why not make that a subscriptions-comments template?

salvis’s picture

Good questions! See #210737: apply "type" template for "nid" subscriptions

Care to analyze the situation and provide a patch?

mrtoner’s picture

I read the topic referenced above and your explanation in #6 not only makes sense, but it was how I thought I'd use Subscriptions:

1. If someone "Subscribe[s] to this page", they're only going to get update notifications, so I was going to edit the -nid template to let them know the page was updated.

2. If they choose "To Blog entry content", etc., they're going to get new content notifications and the appropriate content-type notification will go out.

But #7 indicates you've changed this behavior. I'm probably not the one you want to write a patch, because of my lack of experience, but it looks like you'd want to rip out lines 81-88 of subscriptions_mail.module -- or at least add the option to toggle this behavior. Am I on the right track?

I'm not sure how easy it would be, but I'd like all updates to use the -nid template. As it stands, that template is only being used for comments, so I don't see any conflict in adding that functionality.

Don

salvis’s picture

Yes, the thinking in #7 was that update notifications are more like new notifications than like comment notifications, and thus they should use the type-specific templates.

For example, if you've customized the blog template to show come CCK fields that you've added to your blog type, and you update a blog entry, then you'd want to get the blog format, so that you can see what was updated. On the sites that I run, I use !body in the type-specific templates.

OTOH, with single-node (node-nid) subscriptions, when comments are added, there's no need to send the full node again and again — what we really want to see is the comment, and that's what the node-nid template is for.

We could even argue that node-type should be converted to node-nid if it's just for comments...

P.S. "Subscribe to this page" gives you updates and/or comments, depending on the site/user/subscription setting.

mrtoner’s picture

Hmm, I just realized that even with the current behavior, I can get what I want (different notifications for new and updated content) by using the conditions !is_new and !is_updated -- just place the appropriate text between the {{...}}}, right?

Okay, if the node-nid template is for comments and the body of node-nid is never used (because node-type is used instead), why not change the mailkey to node-comments and dump the body field? Of course, I could be the only person confused by a node-nid template that's not used to notify of changed nodes.

RobertNelsonVance’s picture

I am simply lost as to how all the tokens work for subscriptions-digest (for example). I am trying to reformat the emails and don't understand how this works. I've read as much as I can and still cant seem to find any documentation as to the "proper syntax", if you will. Any help would be greatly appreciated. robert@robertnelsonvance.com

salvis’s picture

Please avoid topic drift. Let's discuss #254373: Syntax of the Mail Templates in another topic.

salvis’s picture

Status: Active » Closed (works as designed)

@mrtoner:

Okay, if the node-nid template is for comments and the body of node-nid is never used (because node-type is used instead), why not change the mailkey to node-comments and dump the body field? Of course, I could be the only person confused by a node-nid template that's not used to notify of changed nodes.

The node-nid body is used for notifications about comments. If the node is new or updated, then node-nid is converted into node-type, to give the recipient the benefits of the type-specific template. This is not necessary, if the node is unchanged and only comments were added.

This discussion has prompted to revisit my code and I found that new nodes weren't converted. New nodes can trigger notifications if auto-subscribe is enabled. This is fixed in 5.x-2.x-dev.

mrtoner’s picture

The node-nid body is used for notifications about comments.

I haven't yet updated to the latest dev version, still using 2.0. I'd like to note that when I commented on an article, instead of the body from node-nid being used for the comments, the body from node-type-article was used.

mrtoner’s picture

Something else I noticed: if a content type is Unlisted, the node-nid template is used to send notifications of a changed node. As you put it, salvis, it appears that node-nid is not converted to node-type if the content type is Unlisted.

salvis’s picture

I'd like to note that when I commented on an article, instead of the body from node-nid being used for the comments, the body from node-type-article was used.

What type of subscription was it that triggered the notification?

#11: Yes, you're confirming that it's working as designed. If a content type is unlisted, then normal users will never get a notification that has the format of that type.

Subscriptions is not a trivial module and there's quite a bit of logic under the hood. If you want a description of each and every detail of the inner workings, then read the source code. It's THE description of each and every detail of the inner workings. But, while we're at it, and before you come up with the next special case of the special case: there's the 'subscribe to all content types' permission, which allows those that have it to also subscribe to unlisted content types, but they won't get their node/nids converted to unlisted content types; IMO, if they're using a generally available mechanism, they should receive the same results as the general user. The special permission makes additional functionality available, but it does not change generally available functionality.

When this thread ends, you should have a pretty good picture of what templates are used in which cases. Maybe you'd like to write a small section for the README.txt file that would contain all the information that you would have liked to have from the beginning?

mrtoner’s picture

What type of subscription was it that triggered the notification?

It was a content-type subscription, on updates and on comments. From your previous (quoted) comment, I thought that the node-nid body would be used for this notification.

It's not that I "want a description of each and every detail of the inner workings", but that I need an understanding of what my subscribers will receive when they subscribe to a particular piece of content, so that I can modify the templates appropriately. This all started because I expected a node (thread) subscriber to receive the node-nid notification, but they received a node-type notification.

So, node-nid is converted to node-type, but not if the type is Unlisted.

When I asked what the node-nid body was used for (since node-nid wasn't used if it was converted), you said it was used for comments. That's not always true.

It's not me "coming up" with special cases, just finding the ones you've programmed in. The problem is, I don't know which of these are bugs (you found one above) and which are my misunderstanding. Yes, I could go through the code, but -- ideally -- the module needs to be implemented and documented in such a way that a non-programmer end-user can install and use it with a minimum of effort.

salvis’s picture

What type of subscription was it that triggered the notification?

It was a content-type subscription, on updates and on comments. From your previous (quoted) comment, I thought that the node-nid body would be used for this notification.

No. Converting node/nid to node/type in the case of updates (and now also in the case of new nodes) is the only kind of conversion that I ever mentioned. There's no conversion the other way. IOW, non-node/nid subscriptions use their native mail template, enhanced with the comment part of node/nid if they have comments. If they're unlisted, then the node/type is not available to general users, and it's never converted to.

When I asked what the node-nid body was used for (since node-nid wasn't used if it was converted), you said it was used for comments. That's not always true.

I stand by my statement in #9. Converting non-node/nid subscriptions to node/nid subscriptions is your invention, not mine. In fact #5 made it pretty clear that this is not done.

the module needs to be implemented and documented in such a way that a non-programmer end-user can install and use it with a minimum of effort.

I agree, and this thread shows that it's difficult for me to supply this information in that very form and detail that would suit you — that's why I'm asking you to put together a section for the README.txt file as you would like to find it there. Many others didn't need this, but I'm sure there will be more like you who will appreciate having it.

mrtoner’s picture

I stand by my statement in #9. Converting non-node/nid subscriptions to node/nid subscriptions is your invention, not mine.

Sorry, salvis, but I never indicated that I thought there was a conversion the other way. I was simply asking for clarification of #9, where you said:

The node-nid body is used for notifications about comments.

The problem was, I didn't get a notification using node-nid body for comments on a content-type subscription. If I understand you correctly, now, node-nid body is used in two cases:

1. For comments on an unchanged node (that's how I'm still reading #9 -- and that's not what I see happening)

2. For new and changed nodes where the user doesn't have access to content-type subscriptions

Please let me know if I'm understanding you correctly.

salvis’s picture

Yes, 1. and 2., but only for "subscribe to this page" (aka node/nid) subscriptions. "Type" subscriptions, "taxonomy" subscriptions, and all the other subscriptions types use their own body template all of the time, enhanced with the node/nid comment template for comments.

I never indicated that I thought there was a conversion the other way

Then why do you expect to get a node/nid template from a node/type subscription???

Either there's a conversion, or you get what you asked for (node/type if you ask for node/type, for example)— I don't see a third way, and I don't understand why you won't understand...

There's one and exactly one conversion being done: node/nid to node/type (if the type is available), for "new" and "update" notifications. Period. Aside of that you get what you ask for. This seems pretty simple and straight-forward. Why won't you accept it?

P.S. The code is

          if ($module == 'node' && $field == 'nid' 
               && (!empty($object->_is_updated) || !empty($object->_is_new)) 
               && user_access('subscribe to content types', $user)) {
            $unlisteds = variable_get('subscriptions_unlisted_content_types', array());
            if (isset($object->type) && !in_array($object->type, $unlisteds)) {
              $field = 'type';
              $value = $object->type;
            }
          }
mrtoner’s picture

Salvis, now you're just being argumentative and you're bordering on rude. I'm simply asking for clarification on your module's operation and on the comments you have made in this support request. When you said in #9:

The node-nid body is used for notifications about comments.

you put a period at the end of that sentence. There are no exceptions listed and there are no additional uses listed. I read that as "The node-nid body is used for notifications about all comments and only comments." Of course, at the time I made that post I didn't realize that it was also used for node-nid subscriptions where the user doesn't have access to the content-type subscription -- it's not documented and you hadn't mentioned it up to that point.

If the node is new or updated, then node-nid is converted into node-type, to give the recipient the benefits of the type-specific template.

Again, not documented. Given the lack of docs and the bug you found, there's ample room for my confusion.

This is not necessary, if the node is unchanged and only comments were added.

If by "this" you mean the node-nid to node-type conversion, then I should expect to see the node-nid body used when content in a node-nid subscription (and only a node-nid subscription) has new comments and 1) the content itself is unchanged or 2) the corresponding content-type subscription is unlisted -- right?

So as I understand it, here's how the templates are used:

subscriptions-digest -- New and updated content and comments, when user chooses digest
subscriptions-node-nid -- Updated content and comments, when user does not have access to content-type subscriptions; also provides template for all comments
subscriptions-node-tid -- New and updated content and comments for Category subscriptions
subscriptions-node-type-x -- New and updated content and comments for content of type 'x', when user has access to content-type subscriptions

Have I got it?

salvis’s picture

Sigh... I've been debating whether I should write a long post and try to roll all this up again, but I don't have time for this... sorry....

Your insisting to start from the templates and work your way backwards is, er, backwards. You're probably close, except you're probably missing some "some" and "all" qualifiers in various places. Also, there are a few other permissions involved, too.

What you're doing is taking the result, 42, and asking for all possible calculations, circumstances, and conditions that could give 42 — there's no answer to that question.

r00tk1ll’s picture

I cant get the mail templates to apply at all, I have edited every one of them. What is the trick here, I am getting the generic email for every type of notification.

Thanks

salvis’s picture

Did you upgrade from Subscriptions 1.x-dev? If so, then please go to #261002: Upgrade from 1.x-dev: the 2.0 mail templates aren't used.