如果用戶訪問:用戶帳戶頁面上的Drupal目標參數不持久?
user/register?destination=node/add/listing
然後他們點擊「登錄」或「忘記密碼」選項卡,它不會保持在地址欄的目標參數。即點擊「登錄」,並登錄後,用戶將不會在實際上結束了:
node/add/listing
我想編輯核心用戶模塊,但甚至無法找到要修改正確的地方,我知道這是一個非常糟糕的解決方案。
有誰知道我能得到這個權利?
如果用戶訪問:用戶帳戶頁面上的Drupal目標參數不持久?
user/register?destination=node/add/listing
然後他們點擊「登錄」或「忘記密碼」選項卡,它不會保持在地址欄的目標參數。即點擊「登錄」,並登錄後,用戶將不會在實際上結束了:
node/add/listing
我想編輯核心用戶模塊,但甚至無法找到要修改正確的地方,我知道這是一個非常糟糕的解決方案。
有誰知道我能得到這個權利?
你所談論的鏈接是靜態鏈接就像你的導航。它們被緩存等等,所以你不能輕易改變它。這種行爲大部分時間都在進行。您通常不想將querystrings轉移到其他鏈接。
要做到這一點,我認爲最好的辦法是不要直接做在Drupal,而是用JavaScript做到這一點。您可以設置一個js變量或者檢查document.URL
。
你也許可以Drupal的範圍內做到這一點,但考慮到具體的情況下,它不會是值得的。
我碰到這個來尋找同樣的問題時,(我正在試圖找到一個核心問題,但未能)。無論如何,我最終落實到位的解決方案比應該的要多,但是完成這項工作。
首先,下載並安裝url_alter module。然後,在自定義模塊中,實現hook_url_outbound_alter()。以下是我使用的代碼,但許多變體都是可能的。
/**
* Implementation of hook_url_outbound_alter().
*
* If the url_alter module is enabled, and email verification is disabled,
* this will pass the destination parameter to the registration and login tabs.
*/
function os_custom_url_outbound_alter(&$path, &$options, $original) {
if (user_is_anonymous() && in_array($original, array('user', 'user/register', 'user/login')) && empty($options['query']) && !variable_get('user_email_verification', TRUE)) {
$options['query'] = drupal_get_destination();
}
}
我想你可以通過主題菜單鏈接來做到這一點。我在這裏爲Drupal 6寫了http://tappetyclick.com/blog/2013/04/11/maintain-destination-drupal-user-account-menu#.UWbt8hcmdIE的解決方案