Download & Extend

Different templates and fields for different content types

Project:Notifications
Version:6.x-4.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi
I've been testing Notifications over the weekend with a view to replacing Notify.

An impressive piece of work but I ran into one major obstacle which prevents me implementing it at the moment and also seems to be an issue for some other people.

I want people to receive (or preferably have the option of receiving) the full content when they are notified so they don't have to log into the site (just as a reminder - Notify gives option of title or teaser or full content). But the content types are radically different eg they might be a story, a forum post or cck content that contains a library item. It seems I have to use the same format of message for each content type and that just doesn't work. If I use the tokens relating to library items for example, when I receive notifications relating to forum posts the tokens appear unresolved (they could at least be omitted altogether).

Possibly I missed some crucial piece of functionality which already exists and possibly the features I want can be coded up quite quickly by someone who knows what they are doing. Anyway, I seek advice/help. I am not technical at all ie no relevant coding skills but there is a guy who helps me with that stuff.

Thanks in advance.

Comments

#1

Version:5.x-1.x-dev» 6.x-1.x-dev

One idea is for Notifications is to impement a $node->build_mode and then implement CCK's Extensible Contexts hook so that admins can pick which fields are in and which are out for a given content type. Further, they can pick a formatter like 'teaser' versus 'full'.

#2

Title:Templates for different content types» Admin chooses which fields are in the notification for different content types

#3

I had a similar problem and I solved it by making a new token that called a template file (as in phptemplate, not notifications template). That way in the phptemplate file I could do whatever logic or switching I needed to. I'm sure there is a better way to do it (moshe's sounds interesting), and pre-processing things in the template.php file would definitely be cleaner, but this might be useful to someone.

Basically it gives you a token called [themed-teaser] that you can put in your notifications templates and then do all the fancy stuff in php instead of dealing with tokens.

Just put print_r($node_object); in the template file and send yourself a test notification to see everything you've got available.

ps. I put my notifications.tpl.php in the same folder with my other templates, but if you want it with the module you should change the path in the module code.

AttachmentSize
notifications_token.zip 2.84 KB

#4

Also, there is a difference between choosing which fields are in the notification for each content type and having a real template. As you can see in my example, I'm doing some logic to determine language that you wouldn't be able to do with more/different tokens. For that flexibility, actually using the theme system makes a lot of sense to me.

#5

Title:Admin chooses which fields are in the notification for different content types» Different templates and fields for different content types

We are using this (experimental) module atm: Token Logic

Read about it here:

http://www.developmentseed.org/blog/2009/mar/25/tokenlogic-helps-messagi...
http://code.developmentseed.org/token_logic/dashboard

#6

is this module (token logic) bug free ?

Thanks for your responses.

#7

I think this could be useful: http://drupal.org/project/contemplate. It's not perfect though, as you will not be able to make different templates for notifications and pages, and I think it requires you to write PHP code for the template, not use tokens.

#8

UP !

Is it possible to use ONE notification template for each content type ? (contemplate is not useful for that)

#9

Version:6.x-1.x-dev» 6.x-4.x-dev

Will be in this new branch

#10

An add-on module, alpha is in this Notifications Extra package, check out the 'Content Type extension' module.
(Needed some API extensions in the Notifications module though)

See the screenshot attached.

AttachmentSize
screenshot4.png 146.75 KB

#11

Project:Notifications» Notifications Add-ons
Version:6.x-4.x-dev» 6.x-4.x-dev
Component:Code» Content Type extension

Forgot to move to Notifications Add-ons

#12

I have installed messaging and notifications modules 6.4.alpha1 and the Notifications extra module (6.4.developpement) and I have actived the Content Type extension BUT I don't see the options (compared to your screenshot in #10).

What is the problem ?

thanks !

#13

With alpha2, the option's configuration display in the administration section but it does not works. It's the "node creation" template that's send.

#14

Status:active» closed (fixed)

This 'content type extension' has been moved into Notifications package and got some more releases. Open new issues there if any.

#15

Yes, and it seems really usefull !

THANKS !

#16

Has anyone else had any issues with the token logic module?
http://code.developmentseed.org/token_logic/dashboard

Im getting this error;
Fatal error: Call to undefined function _token_replace_tokens() in /home/myserver/public_html/mysite/sites/all/modules/token_logic/token_logic.module on line 144

Thanks

#17

Ive been using sagannotcarl's module successfully for a while but ive just updated Notifications (which i hadn't done for a while) and now its stopped working. Lots of the fields are not coming through in the email.
Thanks

#18

subscribe

#19

Status:closed (fixed)» active

Subscribing, issue with token logic module, has that ever worked? That's the easiest way to make notifications logic but I get same error as #16

Will try out #3 method, is there a settings area for this or just enable and customize the notifications template?

#20

Project:Notifications Add-ons» Notifications
Version:6.x-4.x-dev» 6.x-4.x-dev
Component:Content Type extension» Code

any chance this can be added to the 2.x branch, is it possible or just too much work? I don't mind rolling a patch for that, just wonder if it's at all possible?

#21

any chance this can be added to the 2.x branch, is it possible or just too much work? I don't mind rolling a patch for that, just wonder if it's at all possible?

#22

@sagannotcarl thanks. your solution works for me.