Could you add token support to the premium messages? I would like to add a link to the login page (/user/login) from my messages with the ?destination=node/123 appended to the link.
At present I'm using the following theme override to achieve this but it would be much easier with tokens
function mytheme_nopremium_message($node) {
$message = t(nopremium_get_message($node->type));
$message = preg_replace('/href="\/user\/login"/i', 'href="/user/login?'.drupal_get_destination().'"', $message);
return check_markup($message);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | nopremium-allow_tokens_in_messages-1300340.patch | 713 bytes | elstudio |
Comments
Comment #1
roball commentedThanks for this useful code, SkidNCrashwell. I needed the same, having
set as the Default message at admin/settings/nopremium. I am using
in
template.phpresiding in the THEMENAME directory of the used theme. This solution is a little bit smarter I think.Comment #2
anrikun commented@SkidNCrashwell, @roball:
You don't need
preg_replacehere. A right way to achieve this is:Having as message:
<a href="/user/login?destination=node/!nid"><strong>Log in</strong></a> to read the full content of this article (Members only).Use:
Comment #3
roball commentedExcellent, anrikun, the code gets smarter and smarter. How about integrating the
!nidtoken into your module, so there is no more need to touchtemplate.phpat all, as originally suggested in this issue?Comment #4
anrikun commented!nid token is not enough. I think we should add global and node tokens :-) User tokens too if possible.
Let's do it in 7.x first.
Comment #5
roball commentedSounds like a plan :-) BTW, thank you for this very useful module - it is far better than the original one and the second fork. Just does what it advertises, nothing more, nothing less, and that's exactly how software should work.
Comment #6
varsityblue50 commentedHello there, were the tokens and full HTML issues resolved in the 7.x dev release?
Comment #7
devkinetic commentedI just looked at this and this sounds dead simple. Adding token_replace() to the theme function should be all that is needed as token is built into the D7 API. Looks like the token module is still needed for "... a token UI browser, and token support for core module like Fields and Profile." so what this topic should be about is if we want to extend token support beyond D7 core, and allow for those extra features.
Comment #8
elstudio commentedI've uploaded a patch that allows standard token replacement in the premium messages.
It's set to work with the html-enabled messages from #1149302.