Instead of the following code, how can I use the name of the node (it's title)?

!name has forwarded a page to you from !site

Comments

ngaur’s picture

It'd be nice if this could use the token module rather than implementing a custom templating system.

seanr’s picture

Good suggestion, but it probably won't happen in 5.x as I'm not really developing new features for that at this point (focusing on 6.x and preparing to port to 7.x). Token didn't exist when I wrote this module, but I'm certainly interested in checking it out in the future.

seanr’s picture

Status: Active » Postponed

Marking this as postponed. Having a hard enough time just keeping up with the bugs right now. I suspect I'll be able to come back to it in a month or two though. Obviously, I'd welcome a patch sooner if anyone has the time or ability to provide one.

jeffschuler’s picture

Title: Forward message subject » Use token module for Subject and other fields
Version: 5.x-1.9 » 6.x-1.x-dev

Changing title to more generally describe this issue.

lazysoundsystem’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Postponed » Needs review
StatusFileSize
new15.19 KB

About time for that patch...

This provides just two tokens - for the sender's name and the recipient email addresses - but it sends most things through token_replace().

lazysoundsystem’s picture

StatusFileSize
new16.06 KB

This is almost the same as the previous patch, but passes $node to the forward_form function so $node tokens can be used there too.

john.oltman’s picture

Sounds good - I'll post this to the DEV branch within the next day or two. Thanks!

john.oltman’s picture

Status: Needs review » Needs work

@lazysoundsystem, this is good stuff. The problem is going to be with non-node paths. It's possible for users to place Forward links on non-node pages simply by constructing a URL like "/forward?path=my-view-page". I get the following errors when doing so:

Notice: Undefined variable: node in forward_form_submit() (line 1004 of /var/www/html/sites/all/modules/forward/forward.module).
Notice: Undefined variable: node in forward_form_submit() (line 1019 of /var/www/html/sites/all/modules/forward/forward.module).
Notice: Undefined variable: node in forward_form_submit() (line 1049 of /var/www/html/sites/all/modules/forward/forward.module).
Notice: Undefined variable: node in forward_form_submit() (line 1092 of /var/www/html/sites/all/modules/forward/forward.module).

Also, there is a hard error when you use node tokens in the configuration, and then use Forward links on any non-node paths. This is not a smart thing to configure this way, but it should probably degrade gracefully instead of ending with a hard Drupal error.

Finally, I made this version of the module dependent on the Token module. I would guess most users have Token installed already, but if not, that may create issues for them if they upgrade. Maybe I should create a 7.x-2.x branch instead of adding to 7.x-1.x.

Let me know your thoughts on the above and we can go from there.

lazysoundsystem’s picture

StatusFileSize
new367 bytes
new16.31 KB

Thanks for reviewing this - as you guessed I'd only looked at node pages.

It probably makes sense to pass the rename the argument passed to forward_form() to something other than $node, which would require a little alteration, but I think the errors can be avoided by setting the $node to NULL if we don't have one.

I haven't tested this as I don't have non-node forwarding set up to test it on, but I can do so if this doesn't fix it.

I agree that setting it to 2.x would be a good idea, as administrators would have to change any custom text.

john.oltman’s picture

Assigned: Unassigned » john.oltman
Status: Needs work » Needs review

Okay I took your latest change, added some protection for node tokens when on a non-node path, and committed to 7.x-2.x. Should be a 2.x DEV version available soon.

The protection for node tokens means that if you use a node token but the user is forwarding a non-node path, the token is not replaced. But at least the hard error is gone. This is a DEV release so we have time to figure out if more is needed in terms of warning developers about this issue.

john.oltman’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
john.oltman’s picture

Status: Needs review » Closed (fixed)