我的解決辦法找到了完全符合一個訂閱當前節點(如果存在),並組成要麼是提供給該模板的susbcribe或退訂鏈接:
// find subscription
$subs = notifications_user_get_subscriptions(
$user->uid,
'node',
$topic->nid,
$topic,
FALSE);
// compose link
$destination = "?destination=forum/idea-exchange";
if ($subs) {
foreach ($subs as $key => $sub) {
$link = notifications_get_link('unsubscribe', array(
'sid' => $sub->sid,
'confirm' => FALSE));
$variables['topics'][$id]->subscribe_link =
'<a class="unsubscribe" href="/'.$link['href'].
$destination.'">'.t('Stop tracking this topic').'</a>';
break;
}
}
else {
$link = notifications_get_link(
'subscribe',
array('uid' => $user->uid,
'type' => 'thread',
'fields' => array('nid' => $topic->nid),
'confirm' => FALSE));
$variables['topics'][$id]->subscribe_link =
'<a class="subscribe" href="/'.
$link['href'].$destination.'">'.t('Track this topic').'</a>';
}
我結束了使用CCK計算字段此這樣我可以將它包含在View中。有關更多上下文,請參閱this。